Skip to content

Commit

Permalink
HTTP_Request -> HTTP_Request2
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jan 11, 2012
1 parent dce519e commit c8c0a32
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions tests/HTTP_Header2Test.php
Expand Up @@ -7,6 +7,7 @@

require_once 'PHPUnit/Framework/TestCase.php';
require_once 'HTTP/Header2.php';
require_once 'HTTP/Request2.php';

class HTTP_Header2Test extends PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -78,25 +79,23 @@ function testgetHeader()

function testsendHeaders()
{
require_once 'HTTP/Request.php';
$r = new HTTP_Request($this->testScript);
$r->setMethod(HTTP_REQUEST_METHOD_GET);
$r = new HTTP_Request2($this->testScript);
$r->setMethod(HTTP_Request2::METHOD_GET);
$r->addQueryString('X-Foo', 'blablubb');
$r->sendRequest();
$this->assertEquals('blablubb', $r->getResponseHeader('x-foo'));
$response = $r->send();
$this->assertEquals('blablubb', $response->getHeader('x-foo'));
unset($h, $r);
}

function testsendStatusCode()
{
require_once 'HTTP/Request.php';
$r = new HTTP_Request($this->testScript);
$r->setMethod(HTTP_REQUEST_METHOD_GET);
$r->sendRequest();
$this->assertEquals(200, $r->getResponseCode(), 'test for response code 200');
$r = new HTTP_Request2($this->testScript);
$r->setMethod(HTTP_Request2::METHOD_GET);
$response = $r->send();
$this->assertEquals(200, $response->getStatus(), 'test for response code 200');
$r->addQueryString('status', 500);
$r->sendRequest();
$this->assertEquals(500, $r->getResponseCode(), 'test for response code 500');
$response = $r->send();
$this->assertEquals(500, $response->getStatus(), 'test for response code 500');
unset($h, $r);
}

Expand All @@ -109,13 +108,12 @@ function testdateToTimestamp()

function testredirect()
{
require_once 'HTTP/Request.php';
$r = new HTTP_Request($this->testScript, array('allowRedirects' => false));
$r->setMethod(HTTP_REQUEST_METHOD_GET);
$r = new HTTP_Request2($this->testScript, array('allowRedirects' => false));
$r->setMethod(HTTP_Request2::METHOD_GET);
$r->addQueryString('redirect', 'response.php?abc=123');
$r->sendRequest();
$this->assertEquals(302, $r->getResponseCode(), 'test for response code 302');
$this->assertTrue(strstr($r->getResponseHeader('location'), 'response.php'));
$response = $r->send();
$this->assertEquals(302, $response->getStatus(), 'test for response code 302');
$this->assertTrue(strstr($response->getHeader('location'), 'response.php'));
unset($h, $r);
}

Expand Down

0 comments on commit c8c0a32

Please sign in to comment.