-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates namespace structure updates test coverage and coverage reporting
- Loading branch information
Showing
9 changed files
with
97 additions
and
59 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,8 @@ | ||
#!/bin/bash | ||
|
||
|
||
if [ "5.5" = "$(phpenv version-name)" ]; then | ||
composer require satooshi/php-coveralls:dev-master | ||
vendor/bin/coveralls -v | ||
fi | ||
|
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
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
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 |
---|---|---|
@@ -1,52 +1,94 @@ | ||
<?php | ||
|
||
use sndsgd\http\Header; | ||
namespace sndsgd\http; | ||
|
||
|
||
class HeaderTest extends PHPUnit_Framework_TestCase | ||
/** | ||
* @coversDefaultClass \sndsgd\http\Header | ||
*/ | ||
class HeaderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected static $rawHeaders = []; | ||
protected static $headers = []; | ||
|
||
public static function setUpBeforeClass() | ||
/** | ||
* @coversNothing | ||
*/ | ||
public static function addHeader($name, $content) | ||
{ | ||
$dir = __DIR__.DIRECTORY_SEPARATOR.'headers'; | ||
$files = array_diff(scandir($dir), ['.', '..']); | ||
foreach ($files as $file) { | ||
$path = $dir.DIRECTORY_SEPARATOR.$file; | ||
$contents = file_get_contents($path); | ||
self::$rawHeaders[$file] = str_replace("\n", "\r\n", $contents); | ||
} | ||
self::$headers[$name] = str_replace("\n", "\r\n", $content); | ||
} | ||
|
||
/** | ||
* @coversNothing | ||
*/ | ||
public static function tearDownAfterClass() | ||
{ | ||
self::$rawHeaders = null; | ||
self::$headers = null; | ||
} | ||
|
||
/** | ||
* @covers \sndsgd\http\Header | ||
*/ | ||
public function testParseHttpGoogle() | ||
{ | ||
$h = Header::parse(self::$rawHeaders['http-google.com']); | ||
$h = Header::parse(self::$headers['http://google.com']); | ||
$this->assertEquals('HTTP/1.1', $h->getProtocol()); | ||
$this->assertEquals(301, $h->getStatusCode()); | ||
$this->assertEquals('Moved Permanently', $h->getStatusText()); | ||
$this->assertEquals(219, $h->getFieldValue('content-length')); | ||
} | ||
|
||
/** | ||
* @covers \sndsgd\http\Header | ||
*/ | ||
public function testParseHttpsGoogle() | ||
{ | ||
$h = Header::parse(self::$rawHeaders['https-www.google.com']); | ||
$h = Header::parse(self::$headers['https://www.google.com']); | ||
$this->assertEquals('HTTP/1.1', $h->getProtocol()); | ||
$this->assertEquals(200, $h->getStatusCode()); | ||
$this->assertEquals('OK', $h->getStatusText()); | ||
$this->assertNull($h->getFieldValue('content-length')); | ||
} | ||
|
||
/** | ||
* @covers \sndsgd\http\Header | ||
* @expectedException InvalidArgumentException | ||
*/ | ||
public function testBadHeader() | ||
{ | ||
$h = Header::parse("HTTP/1.1 200 OK\nContent-Length: 219\n"); | ||
Header::parse("HTTP/1.1 200 OK\nContent-Length: 219\n"); | ||
} | ||
} | ||
|
||
|
||
HeaderTest::addHeader('http://google.com', <<<HEADER | ||
HTTP/1.1 301 Moved Permanently | ||
Alternate-Protocol: 80:quic,p=0.01 | ||
Cache-Control: public, max-age=2592000 | ||
Content-Length: 219 | ||
Content-Type: text/html; charset=UTF-8 | ||
Date: Tue, 11 Nov 2014 19:05:32 GMT | ||
Expires: Thu, 11 Dec 2014 19:05:32 GMT | ||
Location: http://www.google.com/ | ||
Server: gws | ||
X-Frame-Options: SAMEORIGIN | ||
X-XSS-Protection: 1; mode=block | ||
HEADER | ||
); | ||
|
||
HeaderTest::addHeader('https://www.google.com', <<<HEADER | ||
HTTP/1.1 200 OK | ||
Alternate-Protocol: 443:quic,p=0.01 | ||
Cache-Control: private, max-age=0 | ||
Content-Type: text/html; charset=ISO-8859-1 | ||
Date: Tue, 11 Nov 2014 19:31:45 GMT | ||
Expires: -1 | ||
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info." | ||
Server: gws | ||
Set-Cookie: PREF=ID=471601aaf6d05f78:FF=0:TM=1415734305:LM=1415734305:S=LMH3Xd8mevGWt0kG; expires=Thu, 10-Nov-2016 19:31:45 GMT; path=/; domain=.google.com | ||
Set-Cookie: NID=asdasdasd; expires=Wed, 13-May-2015 19:31:45 GMT; path=/; domain=.google.com; HttpOnly | ||
Transfer-Encoding: chunked | ||
X-Frame-Options: SAMEORIGIN | ||
X-XSS-Protection: 1; mode=block | ||
HEADER | ||
); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.