Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c251a36

Browse filesBrowse files
johnkaryfabpot
authored andcommitted
[HttpFoundation] Add tests for Cookie
1 parent 4f6256b commit c251a36
Copy full SHA for c251a36

File tree

Expand file treeCollapse file tree

1 file changed

+82
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+82
-0
lines changed
+82Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Tests\Component\HttpFoundation;
13+
14+
use Symfony\Component\HttpFoundation\Cookie;
15+
16+
/**
17+
* CookieTest
18+
*
19+
* @author John Kary <john@johnkary.net>
20+
*/
21+
class CookieTest extends \PHPUnit_Framework_TestCase
22+
{
23+
public function invalidNames()
24+
{
25+
return array(
26+
array(''),
27+
array(",MyName"),
28+
array(";MyName"),
29+
array(" MyName"),
30+
array("\tMyName"),
31+
array("\rMyName"),
32+
array("\nMyName"),
33+
array("\013MyName"),
34+
array("\014MyName"),
35+
);
36+
}
37+
38+
public function invalidValues()
39+
{
40+
return array(
41+
array(",MyValue"),
42+
array(";MyValue"),
43+
array(" MyValue"),
44+
array("\tMyValue"),
45+
array("\rMyValue"),
46+
array("\nMyValue"),
47+
array("\013MyValue"),
48+
array("\014MyValue"),
49+
);
50+
}
51+
52+
/**
53+
* @dataProvider invalidNames
54+
* @expectedException InvalidArgumentException
55+
* @covers Symfony\Component\HttpFoundation\Cookie::__construct
56+
*/
57+
public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidCharacters($name)
58+
{
59+
new Cookie($name);
60+
}
61+
62+
/**
63+
* @dataProvider invalidValues
64+
* @expectedException InvalidArgumentException
65+
* @covers Symfony\Component\HttpFoundation\Cookie::__construct
66+
*/
67+
public function testInstantiationThrowsExceptionIfCookieValueContainsInvalidCharacters($value)
68+
{
69+
new Cookie('MyCookie', $value);
70+
}
71+
72+
/**
73+
* @covers Symfony\Component\HttpFoundation\Cookie::getValue
74+
*/
75+
public function testGetValue()
76+
{
77+
$value = 'MyValue';
78+
$cookie = new Cookie('MyCookie', $value);
79+
80+
$this->assertSame($value, $cookie->getValue(), '->getValue() returns the proper value');
81+
}
82+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.