From 0b02a6d123b2014705998c94ddf3d460948d3eac Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 10 May 2016 17:26:44 -0700 Subject: initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import) --- .../sabre/dav/tests/Sabre/DAV/ServerEventsTest.php | 74 ++++++++++++++++++---- 1 file changed, 61 insertions(+), 13 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/DAV/ServerEventsTest.php') 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 @@ 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); + + + } + } -- cgit v1.2.3