Skip to content

Commit 0fc0052

Browse files
authored
Added some more tests with serverRequest (#9)
* Added some more tests with serverRequest * style fix * cs
1 parent 5443d44 commit 0fc0052

File tree

5 files changed

+65
-9
lines changed

5 files changed

+65
-9
lines changed

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
4+
backupStaticAttributes="true"
55
colors="true"
66
convertErrorsToExceptions="true"
77
convertNoticesToExceptions="true"

src/ServerRequestIntegrationTest.php

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
use Psr\Http\Message\ServerRequestInterface;
77

88
/**
9-
* TODO Write me.
10-
*
119
* @author Tobias Nyholm <[email protected]>
1210
*/
1311
abstract class ServerRequestIntegrationTest extends BaseTest
@@ -32,14 +30,72 @@ protected function setUp()
3230
$this->serverRequest = $this->createSubject();
3331
}
3432

35-
public function testNothing()
33+
public function testGetServerParams()
3634
{
3735
if (isset($this->skippedTests[__FUNCTION__])) {
3836
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
37+
}
38+
39+
$this->assertEquals($_SERVER, $this->serverRequest->getServerParams());
40+
}
41+
42+
public function testGetCookieParams()
43+
{
44+
if (isset($this->skippedTests[__FUNCTION__])) {
45+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
46+
}
47+
48+
$this->assertEquals($_COOKIE, $this->serverRequest->getCookieParams());
49+
}
50+
51+
public function testWithCookieParams()
52+
{
53+
if (isset($this->skippedTests[__FUNCTION__])) {
54+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
55+
}
56+
57+
$orgCookie = $_COOKIE;
58+
$new = $this->serverRequest->withCookieParams(['foo' => 'bar']);
59+
60+
$this->assertEquals($orgCookie, $this->serverRequest->getCookieParams(), 'Super global $_COOKIE MUST NOT change.');
61+
$this->assertNotEquals($orgCookie, $new->getCookieParams());
3962

40-
return;
63+
$this->assertArrayHasKey('foo', $new->getCookieParams());
64+
}
65+
66+
public function testGetQueryParams()
67+
{
68+
if (isset($this->skippedTests[__FUNCTION__])) {
69+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
70+
}
71+
72+
// TODO write me
73+
}
74+
75+
public function testGetUploadedFiles()
76+
{
77+
if (isset($this->skippedTests[__FUNCTION__])) {
78+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
79+
}
80+
81+
// TODO write me
82+
}
83+
84+
public function testGetParsedBody()
85+
{
86+
if (isset($this->skippedTests[__FUNCTION__])) {
87+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
88+
}
89+
90+
// TODO write me
91+
}
92+
93+
public function testGetAttributes()
94+
{
95+
if (isset($this->skippedTests[__FUNCTION__])) {
96+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
4197
}
4298

43-
$this->assertTrue(true);
99+
// TODO write me
44100
}
45101
}

tests/Guzzle/ServerRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class ServerRequestTest extends ServerRequestIntegrationTest
99
{
1010
public function createSubject()
1111
{
12-
return new ServerRequest('GET', '/');
12+
return new ServerRequest('GET', '/', [], null, '1.1', $_SERVER);
1313
}
1414
}

tests/Slim/ServerRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class ServerRequestTest extends ServerRequestIntegrationTest
1212
{
1313
public function createSubject()
1414
{
15-
return new Request('GET', new Uri('http', 'foo.com'), new Headers([]), [], [], new Body(fopen('php://temp', 'r+')));
15+
return new Request('GET', new Uri('http', 'foo.com'), new Headers([]), $_COOKIE, $_SERVER, new Body(fopen('php://temp', 'r+')));
1616
}
1717
}

tests/Zend/ServerRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class ServerRequestTest extends ServerRequestIntegrationTest
99
{
1010
public function createSubject()
1111
{
12-
return new ServerRequest();
12+
return new ServerRequest($_SERVER);
1313
}
1414
}

0 commit comments

Comments
 (0)