ILIAS  release_7 Revision v7.30-3-g800a261c036
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 24 of file CookieJarWrapperTest.php.

Member Function Documentation

◆ setUpBeforeClass()

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

Definition at line 37 of file CookieJarWrapperTest.php.

37  : void
38  {
39  parent::setUpBeforeClass(); // TODO: Change the autogenerated stub
40  self::$cookieFactory = new CookieFactoryImpl();
41  self::$cookieJarFactory = new CookieJarFactoryImpl();
42  }

◆ testWithDoesNotChangeTheCurrentObject()

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

Definition at line 48 of file CookieJarWrapperTest.php.

49  {
50  $cookieName = "YummyCookie";
51  $cookieValue = "MilkAndChocolate";
52  $cookie = self::$cookieFactory->create($cookieName, $cookieValue);
53  $cookieJar = self::$cookieJarFactory->fromCookieStrings([]);
54 
55  $newCookieJar = $cookieJar->with($cookie);
56 
57  $this->assertFalse($cookieJar->has($cookieName));
58  $this->assertTrue($newCookieJar->has($cookieName));
59 
60  $this->assertNotEquals($cookieJar, $newCookieJar);
61  }

◆ testWithoutDoesNotChangeTheCurrentObject()

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

Definition at line 67 of file CookieJarWrapperTest.php.

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

Field Documentation

◆ $cookieFactory

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

Definition at line 30 of file CookieJarWrapperTest.php.

◆ $cookieJarFactory

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

Definition at line 34 of file CookieJarWrapperTest.php.


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