]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/ServerEventsTest.php
Merge branch '3.6-release'
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAV / ServerEventsTest.php
1 <?php
2
3 require_once 'Sabre/DAV/AbstractServer.php';
4
5 class Sabre_DAV_ServerEventsTest extends Sabre_DAV_AbstractServer {
6
7     private $tempPath;
8
9     private $exception;
10
11     function testAfterBind() {
12
13         $this->server->subscribeEvent('afterBind',array($this,'afterBindHandler'));
14         $newPath = 'afterBind';
15
16         $this->tempPath = '';
17         $this->server->createFile($newPath,'body');
18         $this->assertEquals($newPath, $this->tempPath);
19
20     }
21
22     function afterBindHandler($path) {
23
24        $this->tempPath = $path;
25
26     }
27
28     function testBeforeBindCancel() {
29
30         $this->server->subscribeEvent('beforeBind', array($this,'beforeBindCancelHandler'));
31         $this->assertFalse($this->server->createFile('bla','body'));
32
33         // Also testing put()
34         $req = new Sabre_HTTP_Request(array(
35             'REQUEST_METHOD' => 'PUT',
36             'REQUEST_URI' => '/foobar',
37         ));
38
39         $this->server->httpRequest = $req;
40         $this->server->exec();
41
42         $this->assertEquals('',$this->server->httpResponse->status);
43
44     }
45
46     function beforeBindCancelHandler() {
47
48         return false;
49
50     }
51
52     function testException() {
53
54         $this->server->subscribeEvent('exception', array($this, 'exceptionHandler'));
55
56         $req = new Sabre_HTTP_Request(array(
57             'REQUEST_METHOD' => 'GET',
58             'REQUEST_URI' => '/not/exisitng',
59         ));
60         $this->server->httpRequest = $req;
61         $this->server->exec();
62
63         $this->assertInstanceOf('Sabre_DAV_Exception_NotFound', $this->exception);
64
65     }
66
67     function exceptionHandler(Exception $exception) {
68
69         $this->exception = $exception;
70
71     }
72
73 }