3 require_once 'Sabre/DAV/AbstractServer.php';
5 class Sabre_DAV_ServerEventsTest extends Sabre_DAV_AbstractServer {
11 function testAfterBind() {
13 $this->server->subscribeEvent('afterBind',array($this,'afterBindHandler'));
14 $newPath = 'afterBind';
17 $this->server->createFile($newPath,'body');
18 $this->assertEquals($newPath, $this->tempPath);
22 function afterBindHandler($path) {
24 $this->tempPath = $path;
28 function testBeforeBindCancel() {
30 $this->server->subscribeEvent('beforeBind', array($this,'beforeBindCancelHandler'));
31 $this->assertFalse($this->server->createFile('bla','body'));
34 $req = new Sabre_HTTP_Request(array(
35 'REQUEST_METHOD' => 'PUT',
36 'REQUEST_URI' => '/foobar',
39 $this->server->httpRequest = $req;
40 $this->server->exec();
42 $this->assertEquals('',$this->server->httpResponse->status);
46 function beforeBindCancelHandler() {
52 function testException() {
54 $this->server->subscribeEvent('exception', array($this, 'exceptionHandler'));
56 $req = new Sabre_HTTP_Request(array(
57 'REQUEST_METHOD' => 'GET',
58 'REQUEST_URI' => '/not/exisitng',
60 $this->server->httpRequest = $req;
61 $this->server->exec();
63 $this->assertInstanceOf('Sabre_DAV_Exception_NotFound', $this->exception);
67 function exceptionHandler(Exception $exception) {
69 $this->exception = $exception;