]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/ServerEventsTest.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[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     function testAfterBind() {
10
11         $this->server->subscribeEvent('afterBind',array($this,'afterBindHandler'));
12         $newPath = 'afterBind';
13
14         $this->tempPath = '';
15         $this->server->createFile($newPath,'body');
16         $this->assertEquals($newPath, $this->tempPath);
17
18     }
19
20     function afterBindHandler($path) {
21
22        $this->tempPath = $path;
23
24     }
25
26     function testBeforeBindCancel() {
27
28         $this->server->subscribeEvent('beforeBind', array($this,'beforeBindCancelHandler'));
29         $this->assertFalse($this->server->createFile('bla','body'));
30
31         // Also testing put()
32         $req = new Sabre_HTTP_Request(array(
33             'REQUEST_METHOD' => 'PUT',
34             'REQUEST_URI' => '/foobar',
35         ));
36
37         $this->server->httpRequest = $req;
38         $this->server->exec();
39
40         $this->assertEquals('',$this->server->httpResponse->status);
41
42     }
43
44     function beforeBindCancelHandler() {
45
46         return false;
47
48     }
49
50
51 }