ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
CookieTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Dflydev\FigCookies;
4 
6 {
11  public function it_parses_one_from_cookie_string($cookieString, $expectedName, $expectedValue)
12  {
13  $cookie = Cookie::oneFromCookiePair($cookieString);
14 
15  $this->assertCookieNameAndValue($cookie, $expectedName, $expectedValue);
16  }
17 
22  public function it_parses_list_from_cookie_string($cookieString, array $expectedNameValuePairs)
23  {
24  $cookies = Cookie::listFromCookieString($cookieString);
25 
26  $this->assertCount(count($expectedNameValuePairs), $cookies);
27 
28  for ($i = 0; $i < count($cookies); $i++) {
29  $cookie = $cookies[$i];
30  list ($expectedName, $expectedValue) = $expectedNameValuePairs[$i];
31 
32  $this->assertCookieNameAndValue($cookie, $expectedName, $expectedValue);
33  }
34  }
35 
36  private function assertCookieNameAndValue(Cookie $cookie, $expectedName, $expectedValue)
37  {
38  $this->assertEquals($expectedName, $cookie->getName());
39  $this->assertEquals($expectedValue, $cookie->getValue());
40  }
41 
43  {
44  return [
45  ['someCookie=something', 'someCookie', 'something'],
46  ['hello%3Dworld=how%22are%27you', 'hello=world', 'how"are\'you'],
47  ['empty=', 'empty', ''],
48  ];
49  }
50 
52  {
53  return [
54  ['theme=light; sessionToken=abc123', [
55  ['theme', 'light'],
56  ['sessionToken', 'abc123'],
57  ]],
58 
59  ['theme=light; sessionToken=abc123;', [
60  ['theme', 'light'],
61  ['sessionToken', 'abc123'],
62  ]],
63  ];
64  }
65 }
static listFromCookieString($string)
Create a list of Cookies from a Cookie header value string.
Definition: Cookie.php:84
it_parses_list_from_cookie_string($cookieString, array $expectedNameValuePairs)
Definition: CookieTest.php:22
assertCookieNameAndValue(Cookie $cookie, $expectedName, $expectedValue)
Definition: CookieTest.php:36
Create styles array
The data for the language used.
$i
Definition: disco.tpl.php:19
it_parses_one_from_cookie_string($cookieString, $expectedName, $expectedValue)
Definition: CookieTest.php:11