Skip to content

Commit f92f457

Browse files
committed
Cookies must have a name
1 parent e5de81c commit f92f457

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/Cookie/HttpCookiesTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Mvc5\Cookie\HttpCookies;
99
use Mvc5\Test\Test\TestCase;
10+
use PHPUnit\Framework\Error\Notice;
1011

1112
use const Mvc5\Cookie\Config\EXPIRE_TIME;
1213

@@ -176,4 +177,40 @@ function test_without_associative_array_with_options()
176177
$this->assertNotEquals($cookies, $new);
177178
$this->assertEquals($expired, $new['foo']);
178179
}
180+
181+
/**
182+
*
183+
*/
184+
function test_invalid_name()
185+
{
186+
$cookies = new HttpCookies;
187+
188+
try {
189+
190+
$cookies->without([]);
191+
192+
} catch(Notice $e) {
193+
194+
$this->assertEquals('Undefined offset: 0', $e->getMessage());
195+
196+
}
197+
}
198+
199+
/**
200+
*
201+
*/
202+
function test_invalid_associative_name()
203+
{
204+
$cookies = new HttpCookies;
205+
206+
try {
207+
208+
$cookies->without(['value' => '']);
209+
210+
} catch(Notice $e) {
211+
212+
$this->assertEquals('Undefined index: name', $e->getMessage());
213+
214+
}
215+
}
179216
}

0 commit comments

Comments
 (0)