ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ILIAS\HTTP\Cookies\CookieWrapperTest Class Reference

Class CookieWrapperTest. More...

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

Public Member Functions

 testWithValueDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testWithExpiresDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testRememberForeverDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testExpireDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testWithMaxAgeDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testWithPathDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testWithDomainDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testWithSecureDoesNotChangeTheCurrentObject ()
 @Test More...
 
 testWithHttpOnlyDoesNotChangeTheCurrentObject ()
 @Test More...
 

Static Public Member Functions

static setUpBeforeClass ()
 

Protected Member Functions

 setUp ()
 

Private Attributes

 $cookie
 

Static Private Attributes

static $cookieFactory
 

Detailed Description

Class CookieWrapperTest.

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

@runInSeparateProcess @preserveGlobalState disabled @backupGlobals disabled @backupStaticAttributes disabled

Definition at line 22 of file CookieWrapperTest.php.

Member Function Documentation

◆ setUp()

ILIAS\HTTP\Cookies\CookieWrapperTest::setUp ( )
protected

Definition at line 42 of file CookieWrapperTest.php.

43 {
44 parent::setUp();
45
46 //setup the cookie we want to use for our tests.
47 $cookieName = "ilias";
48 $cookieValue = "theNewCookiesAreYummy";
49 $this->cookie = self::$cookieFactory->create($cookieName, $cookieValue);
50 }
$cookieName

References $cookieName.

◆ setUpBeforeClass()

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

Definition at line 35 of file CookieWrapperTest.php.

36 {
37 parent::setUpBeforeClass();
38 self::$cookieFactory = new CookieFactoryImpl();
39 }

◆ testExpireDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testExpireDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 93 of file CookieWrapperTest.php.

94 {
95 $newCookie = $this->cookie->expire();
96
97 //expire changes the date of expiry so they should differ by quite a bit.
98 $this->assertNotEquals($this->cookie->getExpires(), $newCookie->getExpires());
99 }

◆ testRememberForeverDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testRememberForeverDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 81 of file CookieWrapperTest.php.

82 {
83 $newCookie = $this->cookie->rememberForLongTime();
84
85 //remember forever changes the date of expiry so they should differ by quite a bit.
86 $this->assertNotEquals($this->cookie->getExpires(), $newCookie->getExpires());
87 }

◆ testWithDomainDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testWithDomainDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 131 of file CookieWrapperTest.php.

132 {
133 $domain = 'ilias.de';
134 $newCookie = $this->cookie->withDomain($domain);
135
136 $this->assertEquals($domain, $newCookie->getDomain());
137 $this->assertNotEquals($this->cookie->getDomain(), $newCookie->getDomain());
138 }
if(!array_key_exists('domain', $_REQUEST)) $domain
Definition: resume.php:8

References $domain.

◆ testWithExpiresDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testWithExpiresDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 68 of file CookieWrapperTest.php.

69 {
70 $expires = 1000;
71 $newCookie = $this->cookie->withExpires($expires);
72
73 $this->assertEquals($expires, $newCookie->getExpires());
74 $this->assertNotEquals($this->cookie->getExpires(), $newCookie->getExpires());
75 }

◆ testWithHttpOnlyDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testWithHttpOnlyDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 157 of file CookieWrapperTest.php.

158 {
159 $httpOnly = true;
160 $newCookie = $this->cookie->withHttpOnly($httpOnly);
161
162 $this->assertTrue($newCookie->getHttpOnly());
163 $this->assertNotEquals($this->cookie->getHttpOnly(), $newCookie->getHttpOnly());
164 }

◆ testWithMaxAgeDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testWithMaxAgeDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 105 of file CookieWrapperTest.php.

106 {
107 $maxAge = 1000;
108 $newCookie = $this->cookie->withMaxAge($maxAge);
109
110 $this->assertEquals($maxAge, $newCookie->getMaxAge());
111 $this->assertNotEquals($this->cookie->getMaxAge(), $newCookie->getMaxAge());
112 }

◆ testWithPathDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testWithPathDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 118 of file CookieWrapperTest.php.

119 {
120 $path = '/ilias';
121 $newCookie = $this->cookie->withPath($path);
122
123 $this->assertEquals($path, $newCookie->getPath());
124 $this->assertNotEquals($this->cookie->getPath(), $newCookie->getPath());
125 }

References $path.

◆ testWithSecureDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testWithSecureDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 144 of file CookieWrapperTest.php.

145 {
146 $secure = true;
147 $newCookie = $this->cookie->withSecure($secure);
148
149 $this->assertTrue($newCookie->getSecure());
150 $this->assertNotEquals($this->cookie->getSecure(), $newCookie->getSecure());
151 }

◆ testWithValueDoesNotChangeTheCurrentObject()

ILIAS\HTTP\Cookies\CookieWrapperTest::testWithValueDoesNotChangeTheCurrentObject ( )

@Test

Definition at line 56 of file CookieWrapperTest.php.

57 {
58 $newValue = "yes!";
59 $newCookie = $this->cookie->withValue("yes!");
60 $this->assertEquals($newValue, $newCookie->getValue());
61 $this->assertNotEquals($this->cookie->getValue(), $newCookie->getValue());
62 }

Field Documentation

◆ $cookie

CookieWrapper ILIAS\HTTP\Cookies\CookieWrapperTest::$cookie
private

Definition at line 28 of file CookieWrapperTest.php.

◆ $cookieFactory

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

Definition at line 32 of file CookieWrapperTest.php.


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