ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 22 of file CookieJarWrapperTest.php.

Member Function Documentation

◆ setUpBeforeClass()

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

Definition at line 35 of file CookieJarWrapperTest.php.

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

◆ testWithDoesNotChangeTheCurrentObject()

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

Definition at line 46 of file CookieJarWrapperTest.php.

References $cookieName.

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  }
$cookieName

◆ testWithoutDoesNotChangeTheCurrentObject()

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

Definition at line 65 of file CookieJarWrapperTest.php.

References $cookieName.

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  }
$cookieName

Field Documentation

◆ $cookieFactory

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

Definition at line 28 of file CookieJarWrapperTest.php.

◆ $cookieJarFactory

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

Definition at line 32 of file CookieJarWrapperTest.php.


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