ILIAS  release_8 Revision v8.23
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 $cookieFactory
 
static $cookieJarFactory
 

Detailed Description

Class CookieWrapperTest.

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

disabled disabled disabled

Definition at line 35 of file CookieJarWrapperTest.php.

Member Function Documentation

◆ setUpBeforeClass()

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

Definition at line 47 of file CookieJarWrapperTest.php.

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

◆ testWithDoesNotChangeTheCurrentObject()

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

Definition at line 58 of file CookieJarWrapperTest.php.

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

◆ testWithoutDoesNotChangeTheCurrentObject()

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

Definition at line 77 of file CookieJarWrapperTest.php.

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

Field Documentation

◆ $cookieFactory

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

Definition at line 40 of file CookieJarWrapperTest.php.

◆ $cookieJarFactory

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

Definition at line 44 of file CookieJarWrapperTest.php.


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