This repository has been archived by the owner on Jan 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
81 parents
dad06c3
+
a0078e6
+
9db875b
+
2879406
+
9acc850
+
eddeb7d
+
6de3f68
+
cb8f354
+
5a77057
+
33c15ff
+
9f13ebf
+
a2ad2a5
+
c0ba21c
+
94e82a8
+
459f1f9
+
e0c8424
+
5ef6a39
+
58fd018
+
65e3b0b
+
d21655a
+
1d20fd1
+
fe81bc5
+
96fadae
+
072c64d
+
d3c9780
+
9c15ae8
+
66a4342
+
85c9491
+
8ec8384
+
004366f
+
55a086d
+
ac7c7af
+
f02a226
+
00c4ac3
+
3f52720
+
5508474
+
49ed2f6
+
d562686
+
67b42b2
+
bdb1dae
+
9809630
+
7304e37
+
752a5af
+
8181c8f
+
53bdac2
+
c2f9414
+
f6341e9
+
57cde95
+
c750616
+
293054e
+
7432649
+
63f13f6
+
927c00d
+
44e0d4b
+
bc03833
+
1fd7c61
+
de0cb77
+
66e902f
+
24354dc
+
9f886a2
+
845333c
+
96e9a1e
+
52fbeb6
+
7f76d90
+
fec4cec
+
24efdcc
+
219c9ad
+
3025666
+
17d48b4
+
00f4506
+
0800032
+
fc89677
+
e89d79b
+
f329014
+
a1bfde3
+
7dec05c
+
734f9f2
+
2756031
+
408f714
+
fd53447
+
f36d9ab
commit f1f6e0d
Showing
2 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_Http | ||
* @subpackage UnitTest | ||
*/ | ||
|
||
namespace ZendTest\Http\PhpEnvironment; | ||
|
||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Zend\Http\PhpEnvironment\Response; | ||
|
||
class ResponseTest extends TestCase | ||
{ | ||
/** | ||
* Original environemnt | ||
* | ||
* @var array | ||
*/ | ||
protected $originalEnvironment; | ||
|
||
/** | ||
* Save the original environment and set up a clean one. | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->originalEnvironment = array( | ||
'post' => $_POST, | ||
'get' => $_GET, | ||
'cookie' => $_COOKIE, | ||
'server' => $_SERVER, | ||
'env' => $_ENV, | ||
'files' => $_FILES, | ||
); | ||
|
||
$_POST = array(); | ||
$_GET = array(); | ||
$_COOKIE = array(); | ||
$_SERVER = array(); | ||
$_ENV = array(); | ||
$_FILES = array(); | ||
} | ||
|
||
/** | ||
* Restore the original environment | ||
*/ | ||
public function tearDown() | ||
{ | ||
$_POST = $this->originalEnvironment['post']; | ||
$_GET = $this->originalEnvironment['get']; | ||
$_COOKIE = $this->originalEnvironment['cookie']; | ||
$_SERVER = $this->originalEnvironment['server']; | ||
$_ENV = $this->originalEnvironment['env']; | ||
$_FILES = $this->originalEnvironment['files']; | ||
} | ||
|
||
public function testReturnsOneOhVersionWhenDetectedInServerSuperglobal() | ||
{ | ||
// HTTP/1.0 | ||
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.0'; | ||
$response = new Response(); | ||
$this->assertSame(Response::VERSION_10, $response->getVersion()); | ||
} | ||
|
||
public function testReturnsOneOneVersionWhenDetectedInServerSuperglobal() | ||
{ | ||
// HTTP/1.1 | ||
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; | ||
$response = new Response(); | ||
$this->assertSame(Response::VERSION_11, $response->getVersion()); | ||
} | ||
|
||
public function testFallsBackToVersionOneOhWhenServerSuperglobalVersionIsNotRecognized() | ||
{ | ||
// unknown protocol or version -> fallback to HTTP/1.0 | ||
$_SERVER['SERVER_PROTOCOL'] = 'zf/2.0'; | ||
$response = new Response(); | ||
$this->assertSame(Response::VERSION_10, $response->getVersion()); | ||
} | ||
|
||
public function testFallsBackToVersionOneOhWhenNoVersionDetectedInServerSuperglobal() | ||
{ | ||
// undefined -> fallback to HTTP/1.0 | ||
unset($_SERVER['SERVER_PROTOCOL']); | ||
$response = new Response(); | ||
$this->assertSame(Response::VERSION_10, $response->getVersion()); | ||
} | ||
|
||
public function testCanExplicitlySetVersion() | ||
{ | ||
$response = new Response(); | ||
$response->setVersion(Response::VERSION_11); | ||
$this->assertSame(Response::VERSION_11, $response->getVersion()); | ||
|
||
$response->setVersion(Response::VERSION_10); | ||
$this->assertSame(Response::VERSION_10, $response->getVersion()); | ||
|
||
$this->setExpectedException('Zend\Http\Exception\InvalidArgumentException'); | ||
$response->setVersion('zf/2.0'); | ||
} | ||
} |