aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
committerredmatrix <git@macgirvin.com>2016-05-10 17:26:44 -0700
commit0b02a6d123b2014705998c94ddf3d460948d3eac (patch)
tree78ff2cab9944a4f5ab3f80ec93cbe1120de90bb2 /vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
parent40b5b6e9d2da7ab65c8b4d38cdceac83a4d78deb (diff)
downloadvolse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.gz
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.tar.bz2
volse-hubzilla-0b02a6d123b2014705998c94ddf3d460948d3eac.zip
initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import)
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php74
1 files changed, 61 insertions, 13 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
index 2c7a074df..6ac20d2da 100644
--- a/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
@@ -1,6 +1,7 @@
<?php
namespace Sabre\DAV;
+
use Sabre\HTTP;
require_once 'Sabre/DAV/AbstractServer.php';
@@ -13,11 +14,11 @@ class ServerEventsTest extends AbstractServer {
function testAfterBind() {
- $this->server->subscribeEvent('afterBind',array($this,'afterBindHandler'));
+ $this->server->on('afterBind', [$this, 'afterBindHandler']);
$newPath = 'afterBind';
$this->tempPath = '';
- $this->server->createFile($newPath,'body');
+ $this->server->createFile($newPath, 'body');
$this->assertEquals($newPath, $this->tempPath);
}
@@ -28,25 +29,41 @@ class ServerEventsTest extends AbstractServer {
}
+ function testAfterResponse() {
+
+ $mock = $this->getMock('stdClass', ['afterResponseCallback']);
+ $mock->expects($this->once())->method('afterResponseCallback');
+
+ $this->server->on('afterResponse', [$mock, 'afterResponseCallback']);
+
+ $this->server->httpRequest = HTTP\Sapi::createFromServerArray([
+ 'REQUEST_METHOD' => 'GET',
+ 'REQUEST_URI' => '/test.txt',
+ ]);
+
+ $this->server->exec();
+
+ }
+
function testBeforeBindCancel() {
- $this->server->subscribeEvent('beforeBind', array($this,'beforeBindCancelHandler'));
- $this->assertFalse($this->server->createFile('bla','body'));
+ $this->server->on('beforeBind', [$this, 'beforeBindCancelHandler']);
+ $this->assertFalse($this->server->createFile('bla', 'body'));
// Also testing put()
- $req = new HTTP\Request(array(
+ $req = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'PUT',
- 'REQUEST_URI' => '/barbar',
- ));
+ 'REQUEST_URI' => '/barbar',
+ ]);
$this->server->httpRequest = $req;
$this->server->exec();
- $this->assertEquals('',$this->server->httpResponse->status);
+ $this->assertEquals(500, $this->server->httpResponse->getStatus());
}
- function beforeBindCancelHandler() {
+ function beforeBindCancelHandler($path) {
return false;
@@ -54,12 +71,12 @@ class ServerEventsTest extends AbstractServer {
function testException() {
- $this->server->subscribeEvent('exception', array($this, 'exceptionHandler'));
+ $this->server->on('exception', [$this, 'exceptionHandler']);
- $req = new HTTP\Request(array(
+ $req = HTTP\Sapi::createFromServerArray([
'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/not/exisitng',
- ));
+ 'REQUEST_URI' => '/not/exisitng',
+ ]);
$this->server->httpRequest = $req;
$this->server->exec();
@@ -73,4 +90,35 @@ class ServerEventsTest extends AbstractServer {
}
+ function testMethod() {
+
+ $k = 1;
+ $this->server->on('method', function($request, $response) use (&$k) {
+
+ $k += 1;
+
+ return false;
+
+ });
+ $this->server->on('method', function($request, $response) use (&$k) {
+
+ $k += 2;
+
+ return false;
+
+ });
+
+ try {
+ $this->server->invokeMethod(
+ new HTTP\Request('BLABLA', '/'),
+ new HTTP\Response(),
+ false
+ );
+ } catch (Exception $e) {}
+
+ $this->assertEquals(2, $k);
+
+
+ }
+
}