Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2013-10-03 00:13:40 +0400
committerThomas Tanghus <thomas@tanghus.net>2013-10-03 00:13:40 +0400
commit965ce5719f1e936c731871360c89e459e9a20bd9 (patch)
tree2e13837c7814b601ccca4fae6224062964ac8c2b /tests/lib/appframework/http/RequestTest.php
parent8035787cb9159e352659c5107e075e901a2499ad (diff)
Modified PUT behaviour
Now only non-parable PUT requests return a stream resource.
Diffstat (limited to 'tests/lib/appframework/http/RequestTest.php')
-rw-r--r--tests/lib/appframework/http/RequestTest.php54
1 files changed, 30 insertions, 24 deletions
diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php
index aaa2328be10..acd61e70919 100644
--- a/tests/lib/appframework/http/RequestTest.php
+++ b/tests/lib/appframework/http/RequestTest.php
@@ -12,6 +12,18 @@ global $data;
class RequestTest extends \PHPUnit_Framework_TestCase {
+ public function setUp() {
+ require_once __DIR__ . '/requeststream.php';
+ if (in_array('fakeinput', stream_get_wrappers())) {
+ stream_wrapper_unregister('fakeinput');
+ }
+ stream_wrapper_register('fakeinput', 'RequestStream');
+ }
+
+ public function tearDown() {
+ stream_wrapper_unregister('fakeinput');
+ }
+
public function testRequestAccessors() {
$vars = array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
@@ -34,7 +46,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
// Always returns null if variable not set.
$this->assertEquals(null, $request->{'flickname'});
- require_once __DIR__ . '/requeststream.php';
}
// urlParams has precedence over POST which has precedence over GET
@@ -123,11 +134,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
global $data;
$data = http_build_query(array('name' => 'John Q. Public', 'nickname' => 'Joey'), '', '&');
- if (in_array('fakeinput', stream_get_wrappers())) {
- stream_wrapper_unregister('fakeinput');
- }
- stream_wrapper_register('fakeinput', 'RequestStream');
-
$vars = array(
'patch' => $data,
'method' => 'PATCH',
@@ -141,21 +147,29 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals('John Q. Public', $result['name']);
$this->assertEquals('Joey', $result['nickname']);
-
- stream_wrapper_unregister('fakeinput');
}
- public function testJsonPatch() {
+ public function testJsonPatchAndPut() {
global $data;
- $data = '{"name": "John Q. Public", "nickname": null}';
- if (in_array('fakeinput', stream_get_wrappers())) {
- stream_wrapper_unregister('fakeinput');
- }
- stream_wrapper_register('fakeinput', 'RequestStream');
+ // PUT content
+ $data = '{"name": "John Q. Public", "nickname": "Joey"}';
+ $vars = array(
+ 'method' => 'PUT',
+ 'server' => array('CONTENT_TYPE' => 'application/json; utf-8'),
+ );
+
+ $request = new Request($vars);
+
+ $this->assertEquals('PUT', $request->method);
+ $result = $request->put;
+
+ $this->assertEquals('John Q. Public', $result['name']);
+ $this->assertEquals('Joey', $result['nickname']);
+ // PATCH content
+ $data = '{"name": "John Q. Public", "nickname": null}';
$vars = array(
- 'patch' => $data,
'method' => 'PATCH',
'server' => array('CONTENT_TYPE' => 'application/json; utf-8'),
);
@@ -167,19 +181,12 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals('John Q. Public', $result['name']);
$this->assertEquals(null, $result['nickname']);
-
- stream_wrapper_unregister('fakeinput');
}
- public function testPutSteam() {
+ public function testPutStream() {
global $data;
$data = file_get_contents(__DIR__ . '/../../../data/testimage.png');
- if (in_array('fakeinput', stream_get_wrappers())) {
- stream_wrapper_unregister('fakeinput');
- }
- stream_wrapper_register('fakeinput', 'RequestStream');
-
$vars = array(
'put' => $data,
'method' => 'PUT',
@@ -195,7 +202,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
try {
$resource = $request->put;
} catch(\LogicException $e) {
- stream_wrapper_unregister('fakeinput');
return;
}
$this->fail('Expected LogicException.');