8000 tests for HeaderBag · richardudovich/symfony@8f46795 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f46795

Browse files
author
Michal Piotrowski
committed
tests for HeaderBag
1 parent 1dd1532 commit 8f46795

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

Lines chang 10000 ed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,49 @@ public function testConstructor()
2424
$this->assertTrue($bag->has('foo'));
2525
}
2626

27+
public function testToStringNull()
28+
{
29+
$bag = new HeaderBag();
30+
$this->assertEquals('', $bag->__toString());
31+
}
32+
33+
public function testToStringNotNull()
34+
{
35+
$bag = new HeaderBag(array('foo' => 'bar'));
36+
$this->assertEquals("Foo: bar\r\n", $bag->__toString());
37+
}
38+
39+
public function testKeys()
40+
{
41+
$bag = new HeaderBag(array('foo' => 'bar'));
42+
$keys = $bag->keys();
43+
$this->assertEquals("foo", $keys[0]);
44+
}
45+
46+
public function testGetDate()
47+
{
48+
$bag = new HeaderBag(array('foo' => 'Tue, 4 Sep 2012 20:00:00 +0200'));
49+
$headerDate = $bag->getDate('foo');
50+
$this->assertInstanceOf('DateTime', $headerDate);
51+
}
52+
53+
/**
54+
* @expectedException \RuntimeException
55+
*/
56+
public function testGetDateException()
57+
{
58+
$bag = new HeaderBag(array('foo' => 'Tue'));
59+
$headerDate = $bag->getDate('foo');
60+
}
61+
62+
public function testGetCacheControlHeader()
63+
{
64+
$bag = new HeaderBag();
65+
$bag->addCacheControlDirective('public', '#a');< 5EC2 /div>
66+
$this->assertTrue($bag->hasCacheControlDirective('public'));
67+
$this->assertEquals('#a', $bag->getCacheControlDirective('public'));
68+
}
69+
2770
/**
2871
* @covers Symfony\Component\HttpFoundation\HeaderBag::all
2972
*/

0 commit comments

Comments
 (0)
0