@@ -29,6 +29,131 @@ public function testGetDomainNameException()
2929 $ this ->session ->getDomainName ();
3030 }
3131
32+ public function testCookiePathDefault ()
33+ {
34+ $ reflection = new \ReflectionClass ($ this ->session );
35+ $ property = $ reflection ->getProperty ('cookiePath ' );
36+ $ property ->setAccessible (true );
37+ $ this ->assertEquals ('/ ' , $ property ->getValue ($ this ->session ));
38+ }
39+
40+ public function testCookiePathSetter ()
41+ {
42+ $ result = $ this ->session ->cookiePath ('/custom/path ' );
43+ $ this ->assertInstanceOf (Session::class, $ result );
44+
45+ $ reflection = new \ReflectionClass ($ this ->session );
46+ $ property = $ reflection ->getProperty ('cookiePath ' );
47+ $ property ->setAccessible (true );
48+ $ this ->assertEquals ('/custom/path ' , $ property ->getValue ($ this ->session ));
49+ }
50+
51+ public function testCookieHttpOnlyDefault ()
52+ {
53+ $ reflection = new \ReflectionClass ($ this ->session );
54+ $ property = $ reflection ->getProperty ('cookieHttpOnly ' );
55+ $ property ->setAccessible (true );
56+ $ this ->assertFalse ($ property ->getValue ($ this ->session ));
57+ }
58+
59+ public function testCookieHttpOnlySetter ()
60+ {
61+ $ result = $ this ->session ->cookieHttpOnly (true );
62+ $ this ->assertInstanceOf (Session::class, $ result );
63+
64+ $ reflection = new \ReflectionClass ($ this ->session );
65+ $ property = $ reflection ->getProperty ('cookieHttpOnly ' );
66+ $ property ->setAccessible (true );
67+ $ this ->assertTrue ($ property ->getValue ($ this ->session ));
68+ }
69+
70+ public function testCookieSecureDefault ()
71+ {
72+ $ reflection = new \ReflectionClass ($ this ->session );
73+ $ property = $ reflection ->getProperty ('cookieSecure ' );
74+ $ property ->setAccessible (true );
75+ $ this ->assertFalse ($ property ->getValue ($ this ->session ));
76+ }
77+
78+ public function testCookieSecureSetter ()
79+ {
80+ $ result = $ this ->session ->cookieSecure (true );
81+ $ this ->assertInstanceOf (Session::class, $ result );
82+
83+ $ reflection = new \ReflectionClass ($ this ->session );
84+ $ property = $ reflection ->getProperty ('cookieSecure ' );
85+ $ property ->setAccessible (true );
86+ $ this ->assertTrue ($ property ->getValue ($ this ->session ));
87+ }
88+
89+ public function testCookieSameSiteDefault ()
90+ {
91+ $ reflection = new \ReflectionClass ($ this ->session );
92+ $ property = $ reflection ->getProperty ('cookieSameSite ' );
93+ $ property ->setAccessible (true );
94+ $ this ->assertEquals ('' , $ property ->getValue ($ this ->session ));
95+ }
96+
97+ public function testCookieSameSiteSetterWithEmptyString ()
98+ {
99+ $ result = $ this ->session ->cookieSameSite ('' );
100+ $ this ->assertInstanceOf (Session::class, $ result );
101+
102+ $ reflection = new \ReflectionClass ($ this ->session );
103+ $ property = $ reflection ->getProperty ('cookieSameSite ' );
104+ $ property ->setAccessible (true );
105+ $ this ->assertEquals ('' , $ property ->getValue ($ this ->session ));
106+ }
107+
108+ public function testCookieSameSiteSetterWithLax ()
109+ {
110+ $ result = $ this ->session ->cookieSameSite ('Lax ' );
111+ $ this ->assertInstanceOf (Session::class, $ result );
112+
113+ $ reflection = new \ReflectionClass ($ this ->session );
114+ $ property = $ reflection ->getProperty ('cookieSameSite ' );
115+ $ property ->setAccessible (true );
116+ $ this ->assertEquals ('Lax ' , $ property ->getValue ($ this ->session ));
117+ }
118+
119+ public function testCookieSameSiteSetterWithStrict ()
120+ {
121+ $ result = $ this ->session ->cookieSameSite ('Strict ' );
122+ $ this ->assertInstanceOf (Session::class, $ result );
123+
124+ $ reflection = new \ReflectionClass ($ this ->session );
125+ $ property = $ reflection ->getProperty ('cookieSameSite ' );
126+ $ property ->setAccessible (true );
127+ $ this ->assertEquals ('Strict ' , $ property ->getValue ($ this ->session ));
128+ }
129+
130+ public function testCookieSameSiteSetterWithInvalidValue ()
131+ {
132+ $ this ->expectException (\InvalidArgumentException::class);
133+ $ this ->expectExceptionMessage ('Invalid value for cookieSameSite ' );
134+ $ this ->session ->cookieSameSite ('None ' );
135+ }
136+
137+ public function testCookieSameSiteSetterWithInvalidValueRandom ()
138+ {
139+ $ this ->expectException (\InvalidArgumentException::class);
140+ $ this ->expectExceptionMessage ('Invalid value for cookieSameSite ' );
141+ $ this ->session ->cookieSameSite ('InvalidValue ' );
142+ }
143+
144+ public function testFluentInterfaceChaining ()
145+ {
146+ $ result = $ this ->session
147+ ->setDomainName ('example.com ' )
148+ ->cookiePath ('/app ' )
149+ ->cookieHttpOnly (true )
150+ ->cookieSecure (true )
151+ ->cookieSameSite ('Strict ' );
152+
153+ $ this ->assertInstanceOf (Session::class, $ result );
154+ $ this ->assertEquals ('example.com ' , $ this ->session ->getDomainName ());
155+ }
156+
32157 protected function setUp (): void
33158 {
34159 $ this ->session = new Session ([]);
0 commit comments