ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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 ()
 
 testWithExpiresDoesNotChangeTheCurrentObject ()
 
 testRememberForeverDoesNotChangeTheCurrentObject ()
 
 testExpireDoesNotChangeTheCurrentObject ()
 
 testWithMaxAgeDoesNotChangeTheCurrentObject ()
 
 testWithPathDoesNotChangeTheCurrentObject ()
 
 testWithDomainDoesNotChangeTheCurrentObject ()
 
 testWithSecureDoesNotChangeTheCurrentObject ()
 
 testWithHttpOnlyDoesNotChangeTheCurrentObject ()
 

Static Public Member Functions

static setUpBeforeClass ()
 

Protected Member Functions

 setUp ()
 

Private Attributes

Cookie $cookie
 

Static Private Attributes

static CookieFactoryImpl $cookieFactory
 

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 CookieWrapperTest.php.

Member Function Documentation

◆ setUp()

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

Definition at line 58 of file CookieWrapperTest.php.

58  : void
59  {
60  parent::setUp();
61 
62  //setup the cookie we want to use for our tests.
63  $cookieName = "ilias";
64  $cookieValue = "theNewCookiesAreYummy";
65  $this->cookie = self::$cookieFactory->create($cookieName, $cookieValue);
66  }

◆ setUpBeforeClass()

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

Definition at line 51 of file CookieWrapperTest.php.

51  : void
52  {
53  parent::setUpBeforeClass();
54  self::$cookieFactory = new CookieFactoryImpl();
55  }

◆ testExpireDoesNotChangeTheCurrentObject()

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

Definition at line 101 of file CookieWrapperTest.php.

101  : void
102  {
103  $newCookie = $this->cookie->expire();
104 
105  //expire changes the date of expiry so they should differ by quite a bit.
106  $this->assertNotSame($this->cookie->getExpires(), $newCookie->getExpires());
107  }

◆ testRememberForeverDoesNotChangeTheCurrentObject()

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

Definition at line 91 of file CookieWrapperTest.php.

91  : void
92  {
93  $newCookie = $this->cookie->rememberForLongTime();
94 
95  //remember forever changes the date of expiry so they should differ by quite a bit.
96  $this->assertNotSame($this->cookie->getExpires(), $newCookie->getExpires());
97  }

◆ testWithDomainDoesNotChangeTheCurrentObject()

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

Definition at line 133 of file CookieWrapperTest.php.

133  : void
134  {
135  $domain = 'ilias.de';
136  $newCookie = $this->cookie->withDomain($domain);
137 
138  $this->assertSame($domain, $newCookie->getDomain());
139  $this->assertNotEquals($this->cookie->getDomain(), $newCookie->getDomain());
140  }

◆ testWithExpiresDoesNotChangeTheCurrentObject()

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

Definition at line 80 of file CookieWrapperTest.php.

80  : void
81  {
82  $expires = 1000;
83  $newCookie = $this->cookie->withExpires($expires);
84 
85  $this->assertSame($expires, $newCookie->getExpires());
86  $this->assertNotSame($this->cookie->getExpires(), $newCookie->getExpires());
87  }

◆ testWithHttpOnlyDoesNotChangeTheCurrentObject()

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

Definition at line 155 of file CookieWrapperTest.php.

155  : void
156  {
157  $httpOnly = true;
158  $newCookie = $this->cookie->withHttpOnly($httpOnly);
159 
160  $this->assertTrue($newCookie->getHttpOnly());
161  $this->assertNotSame($this->cookie->getHttpOnly(), $newCookie->getHttpOnly());
162  }

◆ testWithMaxAgeDoesNotChangeTheCurrentObject()

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

Definition at line 111 of file CookieWrapperTest.php.

111  : void
112  {
113  $maxAge = 1000;
114  $newCookie = $this->cookie->withMaxAge($maxAge);
115 
116  $this->assertSame($maxAge, $newCookie->getMaxAge());
117  $this->assertNotSame($this->cookie->getMaxAge(), $newCookie->getMaxAge());
118  }

◆ testWithPathDoesNotChangeTheCurrentObject()

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

Definition at line 122 of file CookieWrapperTest.php.

References $path.

122  : void
123  {
124  $path = '/ilias';
125  $newCookie = $this->cookie->withPath($path);
126 
127  $this->assertSame($path, $newCookie->getPath());
128  $this->assertNotEquals($this->cookie->getPath(), $newCookie->getPath());
129  }
$path
Definition: ltiservices.php:29

◆ testWithSecureDoesNotChangeTheCurrentObject()

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

Definition at line 144 of file CookieWrapperTest.php.

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

◆ testWithValueDoesNotChangeTheCurrentObject()

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

Definition at line 70 of file CookieWrapperTest.php.

70  : void
71  {
72  $newValue = "yes!";
73  $newCookie = $this->cookie->withValue("yes!");
74  $this->assertSame($newValue, $newCookie->getValue());
75  $this->assertNotEquals($this->cookie->getValue(), $newCookie->getValue());
76  }

Field Documentation

◆ $cookie

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

Definition at line 47 of file CookieWrapperTest.php.

◆ $cookieFactory

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

Definition at line 48 of file CookieWrapperTest.php.


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