summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2013-09-27 14:36:19 +0200
committerThomas Tanghus <thomas@tanghus.net>2013-09-27 14:36:19 +0200
commitd49e982ac8cb32830275e0086cc8e8e8a11a84b1 (patch)
treea3e43f335ee71facd87f57e922369bcf305f3f79 /tests
parent469b309b21b6634b275c485fb09aa5d8d69fe33c (diff)
downloadnextcloud-server-d49e982ac8cb32830275e0086cc8e8e8a11a84b1.tar.gz
nextcloud-server-d49e982ac8cb32830275e0086cc8e8e8a11a84b1.zip
Check if accessor matched request method.
It's easier to find errors in the code if an exception is thrown.
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/appframework/http/RequestTest.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php
index 0371c870cf2..ff4a8357f06 100644
--- a/tests/lib/appframework/http/RequestTest.php
+++ b/tests/lib/appframework/http/RequestTest.php
@@ -14,6 +14,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
public function testRequestAccessors() {
$vars = array(
'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ 'method' => 'GET',
);
$request = new Request($vars);
@@ -73,4 +74,30 @@ class RequestTest extends \PHPUnit_Framework_TestCase {
$request->{'nickname'} = 'Janey';
}
+ /**
+ * @expectedException BadMethodCallException
+ */
+ public function testGetTheMethodRight() {
+ $vars = array(
+ 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ 'method' => 'GET',
+ );
+
+ $request = new Request($vars);
+ $result = $request->post;
+ }
+
+ public function testTheMethodIsRight() {
+ $vars = array(
+ 'get' => array('name' => 'John Q. Public', 'nickname' => 'Joey'),
+ 'method' => 'GET',
+ );
+
+ $request = new Request($vars);
+ $this->assertEquals('GET', $request->method);
+ $result = $request->get;
+ $this->assertEquals('John Q. Public', $result['name']);
+ $this->assertEquals('Joey', $result['nickname']);
+ }
+
}