projects
/
m6w6
/
ext-http
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
don't sanitize URL path by default, and add http\Url::SANITIZE_PATH flag for that
[m6w6/ext-http]
/
phpunit
/
RequestTest.php
diff --git
a/phpunit/RequestTest.php
b/phpunit/RequestTest.php
index fccad01edfec3b93feda3119c8f5c9f6ff9e08c8..56053ee148d5a487db4ee7d091a5a1f20874ac88 100644
(file)
--- a/
phpunit/RequestTest.php
+++ b/
phpunit/RequestTest.php
@@
-28,7
+28,7
@@
class RequestTest extends PHPUnit_Framework_TestCase
protected $r;
function setUp() {
protected $r;
function setUp() {
- $this->r = (new http\
Request\Factory)->createReques
t();
+ $this->r = (new http\
Client\Factory)->createClien
t();
$this->r->setOptions(
array(
"connecttimeout" => 30,
$this->r->setOptions(
array(
"connecttimeout" => 30,
@@
-38,10
+38,8
@@
class RequestTest extends PHPUnit_Framework_TestCase
}
function testClone() {
}
function testClone() {
- $this->r->setUrl("http://dev.iworks.at/ext-http/.print_request.php");
$c = clone $this->r;
$c = clone $this->r;
- $c->setUrl("http://dev.iworks.at/ext-http/.print_headers.php");
- $this->assertNotEquals($this->r->send(), $c->send());
+ $this->assertNotSame($this->r, $c);
}
function testObserver() {
}
function testObserver() {
@@
-61,51
+59,52
@@
class RequestTest extends PHPUnit_Framework_TestCase
}
)
);
}
)
);
- $this->r->set
Url("http://dev.iworks.at/ext-http/")->send(
);
+ $this->r->set
Request(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/"))->send(null
);
$this->assertRegexp("/(\.-)+/", $this->r->pi);
$this->assertCount(3, $this->r->getObservers());
}
function testCookies() {
$this->assertRegexp("/(\.-)+/", $this->r->pi);
$this->assertCount(3, $this->r->getObservers());
}
function testCookies() {
- $this->r->set
Url("http://dev.iworks.at/ext-http/.cookie.php")->send(
);
+ $this->r->set
Request(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.cookie.php"))->send(null
);
$this->assertNotContains("Cookie", (string) $this->r->getRequestMessage());
$this->assertNotContains("Cookie", (string) $this->r->getRequestMessage());
- $this->r->send();
+ $this->r->send(
null
);
$this->assertNotContains("Cookie", (string) $this->r->getRequestMessage());
$this->assertNotContains("Cookie", (string) $this->r->getRequestMessage());
- $this->r->enableCookies()->send();
+ $this->r->enableCookies()->send(
null
);
$this->assertNotContains("Cookie", (string) $this->r->getRequestMessage());
$this->assertNotContains("Cookie", (string) $this->r->getRequestMessage());
- $this->r->send();
+ $this->r->send(
null
);
$this->assertContains("Cookie", (string) $this->r->getRequestMessage());
$this->assertContains("Cookie", (string) $this->r->getRequestMessage());
- $this->assertCount(2, $this->r->getResponseCookies());
+ $this->assertCount(2, $this->r->getResponse
Message()->get
Cookies());
}
function testResetCookies() {
}
function testResetCookies() {
- $this->r->set
Url("http://dev.iworks.at/ext-http/.cookie.php"
);
+ $this->r->set
Request(new http\Client\Request("GET", "http://dev.iworks.at/ext-http/.cookie.php")
);
$this->r->enableCookies();
$this->r->enableCookies();
- $this->r->send();
+ $this->r->send(
null
);
$f = function ($a) { return $a->getCookies(); };
$f = function ($a) { return $a->getCookies(); };
- $c = array_map($f, $this->r->getResponseCookies());
+ $c = array_map($f, $this->r->getResponse
Message()->get
Cookies());
- $this->r->send();
- $this->assertEquals($c, array_map($f, $this->r->getResponseCookies()));
+ $this->r->send(
null
);
+ $this->assertEquals($c, array_map($f, $this->r->getResponse
Message()->get
Cookies()));
$this->r->resetCookies();
$this->r->resetCookies();
- $this->r->send();
- $this->assertNotEquals($c, array_map($f, $this->r->getResponseCookies()));
+ $this->r->send(
null
);
+ $this->assertNotEquals($c, array_map($f, $this->r->getResponse
Message()->get
Cookies()));
}
function testHistory() {
$body = new http\Message\Body;
$body->append("foobar");
}
function testHistory() {
$body = new http\Message\Body;
$body->append("foobar");
- $this->r->setBody($body);
- $this->r->recordHistory = true;
+ $request = new http\Client\Request;
+ $request->setBody($body);
+ $request->setRequestMethod("POST");
+ $request->setRequestUrl("http://dev.iworks.at/ext-http/.print_request.php");
- $this->r->
setMethod("POST")
;
- $this->r->se
tUrl("http://dev.iworks.at/ext-http/.print_request.php"
);
+ $this->r->
recordHistory = true
;
+ $this->r->se
nd($request
);
- $this->r->send();
$this->assertStringMatchesFormat(<<<HTTP
POST /ext-http/.print_request.php HTTP/1.1
User-Agent: %s
$this->assertStringMatchesFormat(<<<HTTP
POST /ext-http/.print_request.php HTTP/1.1
User-Agent: %s
@@
-130,7
+129,9
@@
HTTP
, str_replace("\r", "", $this->r->getHistory()->toString(true))
);
, str_replace("\r", "", $this->r->getHistory()->toString(true))
);
- $this->r->send();
+
+ $this->r->send($request);
+
$this->assertStringMatchesFormat(<<<HTTP
POST /ext-http/.print_request.php HTTP/1.1
User-Agent: %s
$this->assertStringMatchesFormat(<<<HTTP
POST /ext-http/.print_request.php HTTP/1.1
User-Agent: %s