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-10-01 20:13:13 +0200
commitbdad7697ac333ea442b79b5e0e00f90ad5398bc9 (patch)
treed6d409a7b296bbafb1d259da4d248b7c9dc9590d /tests
parent5ade595911261cf47cdad17deb4d1a013f523245 (diff)
downloadnextcloud-server-bdad7697ac333ea442b79b5e0e00f90ad5398bc9.tar.gz
nextcloud-server-bdad7697ac333ea442b79b5e0e00f90ad5398bc9.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']);
+ }
+
}