ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\HTTP\Cookies\CookieJarWrapperTest Class Reference

Class CookieWrapperTest. More...

+ Inheritance diagram for ILIAS\HTTP\Cookies\CookieJarWrapperTest:
+ Collaboration diagram for ILIAS\HTTP\Cookies\CookieJarWrapperTest:

Public Member Functions

 testWithDoesNotChangeTheCurrentObject ()
 
 testWithoutDoesNotChangeTheCurrentObject ()
 

Static Public Member Functions

static setUpBeforeClass ()
 

Static Private Attributes

static CookieFactoryImpl $cookieFactory
 
static CookieJarFactoryImpl $cookieJarFactory
 

Detailed Description

Class CookieWrapperTest.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 42 of file CookieJarWrapperTest.php.

Member Function Documentation

◆ setUpBeforeClass()

static ILIAS\HTTP\Cookies\CookieJarWrapperTest::setUpBeforeClass ( )
static

Definition at line 48 of file CookieJarWrapperTest.php.

48 : void
49 {
50 parent::setUpBeforeClass(); // TODO: Change the autogenerated stub
51 self::$cookieFactory = new CookieFactoryImpl();
52 self::$cookieJarFactory = new CookieJarFactoryImpl();
53 }

◆ testWithDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieJarWrapperTest::testWithDoesNotChangeTheCurrentObject ( )

Definition at line 57 of file CookieJarWrapperTest.php.

57 : void
58 {
59 $cookieName = "YummyCookie";
60 $cookieValue = "MilkAndChocolate";
61 $cookie = self::$cookieFactory->create($cookieName, $cookieValue);
62 $cookieJar = self::$cookieJarFactory->fromCookieStrings([]);
63
64 $newCookieJar = $cookieJar->with($cookie);
65
66 $this->assertFalse($cookieJar->has($cookieName));
67 $this->assertTrue($newCookieJar->has($cookieName));
68
69 $this->assertNotEquals($cookieJar, $newCookieJar);
70 }

◆ testWithoutDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieJarWrapperTest::testWithoutDoesNotChangeTheCurrentObject ( )

Definition at line 74 of file CookieJarWrapperTest.php.

74 : void
75 {
76 $cookieName = "YummyCookie";
77 $cookieValue = "MilkAndChocolate";
78
79 //create a new jar with one cookie
80 $cookieJar = self::$cookieJarFactory->fromCookieStrings([ $cookieName . '=' . $cookieValue . ';' ]);
81
82 //remove cookie
83 $newCookieJar = $cookieJar->without($cookieName);
84
85 //old jar should hold the cookie
86 $this->assertTrue($cookieJar->has($cookieName));
87
88 //new jar should no longer hold the cookie
89 $this->assertFalse($newCookieJar->has($cookieName));
90
91 //check that both are not equal (checked because the has function could fail due to a change in the future)
92 $this->assertNotEquals($cookieJar, $newCookieJar);
93 }

Field Documentation

◆ $cookieFactory

CookieFactoryImpl ILIAS\HTTP\Cookies\CookieJarWrapperTest::$cookieFactory
staticprivate

Definition at line 44 of file CookieJarWrapperTest.php.

◆ $cookieJarFactory

CookieJarFactoryImpl ILIAS\HTTP\Cookies\CookieJarWrapperTest::$cookieJarFactory
staticprivate

Definition at line 45 of file CookieJarWrapperTest.php.


The documentation for this class was generated from the following file: