Skip to content

Commit a7d2d41

Browse files
committed
Updated to 1.1.3 version
1 parent c2a7fdf commit a7d2d41

File tree

2 files changed

+154
-2
lines changed

2 files changed

+154
-2
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ php:
1111
- 5.6
1212
- 7.0
1313
- 7.1
14-
- hhvm
1514
- nightly
1615

1716
matrix:
1817
fast_finish: true
1918
allow_failures:
20-
- php: hhvm
2119
- php: nightly
2220

2321
before_script:

tests/Cookie/Test/CookieTest.php

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,159 @@
2121
*/
2222
final class CookieTest extends TestCase {
2323

24+
/**
25+
* Set cookie.
26+
*
27+
* @runInSeparateProcess
28+
*
29+
* @since 1.1.3
30+
*
31+
* @return void
32+
*/
33+
public function testSetCookie() {
2434

35+
$this->assertTrue(Cookie::set('cookie_name', 'value', 365));
36+
}
37+
38+
/**
39+
* Get item from cookie.
40+
*
41+
* @runInSeparateProcess
42+
*
43+
* @since 1.1.3
44+
*
45+
* @return void
46+
*/
47+
public function testGetCookie() {
48+
49+
$_COOKIE[Cookie::$prefix . 'cookie_name'] = 'value';
50+
51+
$this->assertContains(Cookie::get('cookie_name'), 'value');
52+
}
53+
54+
/**
55+
* Return cookies array.
56+
*
57+
* @runInSeparateProcess
58+
*
59+
* @since 1.1.3
60+
*
61+
* @return void
62+
*/
63+
public function testGetAllCookies() {
64+
65+
$_COOKIE[Cookie::$prefix . 'cookie_name_one'] = 'value';
66+
$_COOKIE[Cookie::$prefix . 'cookie_name_two'] = 'value';
67+
68+
$this->assertArrayHasKey(
69+
70+
Cookie::$prefix . 'cookie_name_two',
71+
Cookie::get()
72+
);
73+
}
74+
75+
/**
76+
* Return cookies array non-existent.
77+
*
78+
* @runInSeparateProcess
79+
*
80+
* @since 1.1.3
81+
*
82+
* @return void
83+
*/
84+
public function testGetAllCookiesNonExistents() {
85+
86+
$this->assertFalse(Cookie::get());
87+
}
88+
89+
/**
90+
* Extract item from cookie then delete cookie and return the item.
91+
*
92+
* @runInSeparateProcess
93+
*
94+
* @since 1.1.3
95+
*
96+
* @return void
97+
*/
98+
public function testPullCookie() {
99+
100+
$_COOKIE[Cookie::$prefix . 'cookie_name'] = 'value';
101+
102+
$this->assertContains(Cookie::pull('cookie_name'), 'value');
103+
}
104+
105+
/**
106+
* Extract item from cookie non-existent.
107+
*
108+
* @runInSeparateProcess
109+
*
110+
* @since 1.1.3
111+
*
112+
* @return void
113+
*/
114+
public function testPullCookieNonExistent() {
115+
116+
$this->assertFalse(Cookie::pull('cookie_name'));
117+
}
118+
119+
/**
120+
* Destroy one cookie.
121+
*
122+
* @runInSeparateProcess
123+
*
124+
* @since 1.1.3
125+
*
126+
* @return void
127+
*/
128+
public function testDestroyOneCookie() {
129+
130+
$_COOKIE[Cookie::$prefix . 'cookie_name'] = 'value';
131+
132+
$this->assertTrue(Cookie::destroy('cookie_name'));
133+
}
134+
135+
/**
136+
* Destroy one cookie non-existent.
137+
*
138+
* @runInSeparateProcess
139+
*
140+
* @since 1.1.3
141+
*
142+
* @return void
143+
*/
144+
public function testDestroyOneCookieNonExistent() {
145+
146+
$this->assertFalse(Cookie::destroy('cookie_name'));
147+
}
148+
149+
/**
150+
* Destroy all cookies.
151+
*
152+
* @runInSeparateProcess
153+
*
154+
* @since 1.1.3
155+
*
156+
* @return void
157+
*/
158+
public function testDestroyAllCookies() {
159+
160+
$_COOKIE[Cookie::$prefix . 'cookie_name_one'] = 'value';
161+
$_COOKIE[Cookie::$prefix . 'cookie_name_two'] = 'value';
162+
163+
$this->assertTrue(Cookie::destroy());
164+
}
165+
166+
/**
167+
* Destroy all cookies non-existents.
168+
*
169+
* @runInSeparateProcess
170+
*
171+
* @since 1.1.3
172+
*
173+
* @return void
174+
*/
175+
public function testDestroyAllCookiesNonExistents() {
176+
177+
$this->assertFalse(Cookie::destroy());
178+
}
25179
}

0 commit comments

Comments
 (0)