Skip to content

Commit b4d1e0e

Browse files
committed
Add more tests
1 parent a402c11 commit b4d1e0e

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

spec/CookieUtilSpec.php

+28-12
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class CookieUtilSpec extends ObjectBehavior
99
/**
1010
* @dataProvider getCookieStrings
1111
*/
12-
function it_parses_cookie_date_string($cookieDateString)
12+
function it_parses_cookie_date_string($cookieDateString, $expectedString)
1313
{
1414
$this->beConstructedThrough('parseDate', [$cookieDateString]);
1515
$this->shouldHaveType('\DateTime');
16-
$this->getTimestamp()->shouldReturn(1596185377);
16+
$this->format(\DateTime::COOKIE)->shouldReturn($expectedString);
1717
}
1818

1919
/**
@@ -33,16 +33,31 @@ function it_returns_false_if_cookie_date_string_is_invalid($cookieDateString)
3333
public function getCookieStrings()
3434
{
3535
return [
36-
['Friday, 31 Jul 20 08:49:37 GMT'],
37-
['Friday, 31-Jul-20 08:49:37 GMT'],
38-
['Fri, 31-Jul-2020 08:49:37 GMT'],
39-
['Fri, 31 Jul 2020 08:49:37 GMT'],
40-
['Fri, 31-07-2020 08:49:37 GMT'],
41-
['Fri, 31-07-20 08:49:37 GMT'],
42-
['Friday, 31-Jul-20 08:49:37 GMT'],
43-
['Fri Jul 31 08:49:37 2020'],
44-
['Fri Jul 31 08:49:37 2020'],
45-
['Friday July 31st 2020, 08:49:37 GMT'],
36+
['Friday, 31 Jul 20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
37+
['Friday, 31-Jul-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
38+
['Fri, 31-Jul-2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
39+
['Fri, 31 Jul 2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
40+
['Fri, 31-07-2020 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
41+
['Fri, 31-07-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
42+
['Friday, 31-Jul-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
43+
['Fri Jul 31 08:49:37 2020', 'Friday, 31-Jul-2020 08:49:37 GMT'],
44+
['Fri Jul 31 08:49:37 2020', 'Friday, 31-Jul-2020 08:49:37 GMT'],
45+
['Friday July 31st 2020, 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'],
46+
// https://github.com/salesforce/tough-cookie/blob/master/test/date_test.js#L52
47+
['Wed, 09 Jun 2021 10:18:14 GMT', 'Wednesday, 09-Jun-2021 10:18:14 GMT'],
48+
['Wed, 09 Jun 2021 22:18:14 GMT', 'Wednesday, 09-Jun-2021 22:18:14 GMT'],
49+
['Tue, 18 Oct 2011 07:42:42.123 GMT', 'Tuesday, 18-Oct-2011 07:42:42 GMT'],
50+
['18 Oct 2011 07:42:42 GMT', 'Tuesday, 18-Oct-2011 07:42:42 GMT'],
51+
['8 Oct 2011 7:42:42 GMT', 'Saturday, 08-Oct-2011 07:42:42 GMT'],
52+
['8 Oct 2011 7:2:42 GMT', 'Saturday, 08-Oct-2011 07:02:42 GMT'],
53+
['Oct 18 2011 07:42:42 GMT', 'Tuesday, 18-Oct-2011 07:42:42 GMT'],
54+
['Tue Oct 18 2011 07:05:03 GMT+0000 (GMT)', 'Tuesday, 18-Oct-2011 07:05:03 GMT+0000'],
55+
['09 Jun 2021 10:18:14 GMT', 'Wednesday, 09-Jun-2021 10:18:14 GMT'],
56+
['01 Jan 1970 00:00:00 GMT', 'Thursday, 01-Jan-1970 00:00:00 GMT'],
57+
['01 Jan 1601 00:00:00 GMT', 'Monday, 01-Jan-1601 00:00:00 GMT'],
58+
['10 Feb 81 13:00:00 GMT', 'Tuesday, 10-Feb-1981 13:00:00 GMT'], // implicit year
59+
['Thu, 17-Apr-2014 02:12:29 GMT', 'Thursday, 17-Apr-2014 02:12:29 GMT'], // dashes
60+
['Thu, 17-Apr-2014 02:12:29 UTC', 'Thursday, 17-Apr-2014 02:12:29 UTC'], // dashes and UTC
4661
];
4762
}
4863

@@ -55,6 +70,7 @@ public function getInvalidCookieDateStrings()
5570
{
5671
return [
5772
['Flursday July 31st 2020, 08:49:37 GMT'],
73+
['99 Jix 3038 48:86:72 ZMT'],
5874
];
5975
}
6076
}

0 commit comments

Comments
 (0)