Skip to content

Commit 99bb937

Browse files
committed
Add invalid cookie name test for RequestFunctionalTest
1 parent 954bac1 commit 99bb937

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
Array
3+
(
4+
[0] => Content-Type: text/plain; charset=utf-8
5+
)
6+
shutdown
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
use Symfony\Component\HttpFoundation\Cookie;
4+
use Symfony\Component\HttpFoundation\Response;
5+
6+
require __DIR__ . '/common.inc';
7+
8+
$r = new Response();
9+
try{
10+
$r->headers->setCookie(new Cookie('Hello + world', 'hodor'));
11+
} catch (\InvalidArgumentException $e){
12+
return null;
13+
}
14+
$r->sendHeaders();

src/Symfony/Component/HttpFoundation/Tests/RequestFunctionalTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public function testCookieSamesite($fixture)
4949
$this->assertStringEqualsFile(__DIR__.sprintf('/Fixtures/%s.expected', $fixture), $result);
5050
}
5151

52+
public function testCookieShouldThrowExceptionForInvalidName()
53+
{
54+
$result = file_get_contents('http://localhost:8054/invalid_cookie_name.php');
55+
$this->assertStringEqualsFile(__DIR__.'/Fixtures/invalid_cookie_name.expected', $result);
56+
}
57+
5258
public function provideCookie()
5359
{
5460
foreach (glob(__DIR__.'/Fixtures/cookie_*.php') as $file) {

0 commit comments

Comments
 (0)