8000 merged branch eventhorizonpl/100ptc_component_httpfundation_p2 (PR #5… · richardudovich/symfony@5040599 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5040599

Browse files
committed
merged branch eventhorizonpl/100ptc_component_httpfundation_p2 (PR symfony#5413)
Commits ------- 0af8778 Response tests Discussion ---------- Response tests Hi, This patch adds some tests to ResponseTest. Best regards, Michal --------------------------------------------------------------------------- by eventhorizonpl at 2012-09-01T09:45:16Z Fixed, thanks for the review. --------------------------------------------------------------------------- by eventhorizonpl at 2012-09-02T19:39:26Z CS fixed. Thanks for the review :)
2 parents a44c8d8 + 0af8778 commit 5040599

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

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

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,99 @@ public function testCreate()
2525
$this->assertEquals('bar', $response->headers->get('foo'));
2626
}
2727

28+
public function testToString()
29+
{
30+
$response = new Response();
31+
$response = explode("\r\n", $response);
32+
$this->assertEquals("HTTP/1.0 200 OK", $response[0]);
33+
$this->assertEquals("Cache-Control: no-cache", $response[1]);
34+
}
35+
36+
public function testClone()
37+
{
38+
$response = new Response();
39+
$responseClone = clone $response;
40+
$this->assertEquals($response, $responseClone);
41+
}
42+
43+
public function testSendHeaders()
44+
{
45+
$response = new Response();
46+
$headers = $response->sendHeaders();
47+
$this->assertObjectHasAttribute('headers', $headers);
48+
$this->assertObjectHasAttribute('content', $headers);
49+
$this->assertObjectHasAttribute('version', $headers);
50+
$this->assertObjectHasAttribute('statusCode', $headers);
51+
$this->assertObjectHasAttribute('statusText', $headers);
52+
$this->assertObjectHasAttribute('charset', $headers);
53+
}
54+
55+
public function testSend()
56+
{
57+
$response = new Response();
58+
$responseSend = $response->send();
59+
$this->assertObjectHasAttribute('headers', $responseSend);
60+
$this->assertObjectHasAttribute('content', $responseSend);
61+
$this->assertObjectHasAttribute('version', $responseSend);
62+
$this->assertObjectHasAttribute('statusCode', $responseSend);
63+
$this->assertObjectHasAttribute('statusText', $responseSend);
64+
$this->assertObjectHasAttribute('charset', $responseSend);
65+
}
66+
67+
public function testGetCharset()
68+
{
69+
$response = new Response();
70+
$charsetOrigin = 'UTF-8';
71+
$response->setCharset($charsetOrigin);
72+
$charset = $response->getCharset();
73+
$this->assertEquals($charsetOrigin, $charset);
74+
}
75+
76+
public function testIsCacheable()
77+
{
78+
$response = new Response();
79+
$this->assertFalse($response->isCacheable());
80+
}
81+
82+
public function testIsCacheableWithSetTtl()
83+
{
84+
$response = new Response();
85+
$response->setTtl(10);
86+
$this->assertTrue($response->isCacheable());
87+
}
88+
89+
public function testMustRevalidate()
90+
{
91+
$response = new Response();
92+
$this->assertFalse($response->mustRevalidate());
93+
}
94+
95+
public function testSetNotModified()
96+
{
97+
$response = new Response();
98+
$modified = $response->setNotModified();
99+
$this->assertObjectHasAttribute('headers', $modified);
100+
$this->assertObjectHasAttribute('content', $modified);
101+
$this->assertObjectHasAttribute('version', $modified);
102+
$this->assertObjectHasAttribute('statusCode', $modified);
103+
$this->assertObjectHasAttribute('statusText', $modified);
104+
$this->assertObjectHasAttribute('charset', $modified);
105+
$this->assertEquals(304, $modified->getStatusCode());
106+
}
107+
108+
public function testIsSuccessful()
109+
{
110+
$response = new Response();
111+
$this->assertTrue($response->isSuccessful());
112+
}
113+
114+
public function testIsNotModified()
115+
{
116+
$response = new Response();
117+
$modified = $response->isNotModified(new Request());
118+
$this->assertFalse($modified);
119+
}
120+
28121
public function testIsValidateable()
29122
{
30123
$response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)));

0 commit comments

Comments
 (0)
0