ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
CookieJarWrapperTest.php
Go to the documentation of this file.
1<?php
8namespace ILIAS\HTTP\Cookies;
9
10require_once('./libs/composer/vendor/autoload.php');
11
23{
24
28 private static $cookieFactory;
32 private static $cookieJarFactory;
33
34
35 public static function setUpBeforeClass()
36 {
37 parent::setUpBeforeClass(); // TODO: Change the autogenerated stub
38 self::$cookieFactory = new CookieFactoryImpl();
39 self::$cookieJarFactory = new CookieJarFactoryImpl();
40 }
41
42
47 {
48 $cookieName = "YummyCookie";
49 $cookieValue = "MilkAndChocolate";
50 $cookie = self::$cookieFactory->create($cookieName, $cookieValue);
51 $cookieJar = self::$cookieJarFactory->fromCookieStrings([]);
52
53 $newCookieJar = $cookieJar->with($cookie);
54
55 $this->assertFalse($cookieJar->has($cookieName));
56 $this->assertTrue($newCookieJar->has($cookieName));
57
58 $this->assertNotEquals($cookieJar, $newCookieJar);
59 }
60
61
66 {
67 $cookieName = "YummyCookie";
68 $cookieValue = "MilkAndChocolate";
69
70 //create a new jar with one cookie
71 $cookieJar = self::$cookieJarFactory->fromCookieStrings([ $cookieName . '=' . $cookieValue . ';' ]);
72
73 //remove cookie
74 $newCookieJar = $cookieJar->without($cookieName);
75
76 //old jar should hold the cookie
77 $this->assertTrue($cookieJar->has($cookieName));
78
79 //new jar should no longer hold the cookie
80 $this->assertFalse($newCookieJar->has($cookieName));
81
82 //check that both are not equal (checked because the has function could fail due to a change in the future)
83 $this->assertNotEquals($cookieJar, $newCookieJar);
84 }
85}
An exception for terminatinating execution or to throw for unit testing.
Class CookieJarWrapperTest.
Definition: Cookie.php:3
$cookieName