aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php
diff options
context:
space:
mode:
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);
+
+
+ }
+
}