1<?php
2
3namespace Sabre\DAV\Browser;
4
5class PropFindAllTest extends \PHPUnit_Framework_TestCase {
6
7    function testHandleSimple() {
8
9        $pf = new PropFindAll('foo');
10        $pf->handle('{DAV:}displayname', 'foo');
11
12        $this->assertEquals(200, $pf->getStatus('{DAV:}displayname'));
13        $this->assertEquals('foo', $pf->get('{DAV:}displayname'));
14
15
16    }
17
18    function testHandleCallBack() {
19
20        $pf = new PropFindAll('foo');
21        $pf->handle('{DAV:}displayname', function() { return 'foo'; });
22
23        $this->assertEquals(200, $pf->getStatus('{DAV:}displayname'));
24        $this->assertEquals('foo', $pf->get('{DAV:}displayname'));
25
26    }
27
28    function testSet() {
29
30        $pf = new PropFindAll('foo');
31        $pf->set('{DAV:}displayname', 'foo');
32
33        $this->assertEquals(200, $pf->getStatus('{DAV:}displayname'));
34        $this->assertEquals('foo', $pf->get('{DAV:}displayname'));
35
36    }
37
38    function testSetNull() {
39
40        $pf = new PropFindAll('foo');
41        $pf->set('{DAV:}displayname', null);
42
43        $this->assertEquals(404, $pf->getStatus('{DAV:}displayname'));
44        $this->assertEquals(null, $pf->get('{DAV:}displayname'));
45
46    }
47
48    function testGet404Properties() {
49
50        $pf = new PropFindAll('foo');
51        $pf->set('{DAV:}displayname', null);
52        $this->assertEquals(
53            ['{DAV:}displayname'],
54            $pf->get404Properties()
55        );
56
57    }
58
59    function testGet404PropertiesNothing() {
60
61        $pf = new PropFindAll('foo');
62        $pf->set('{DAV:}displayname', 'foo');
63        $this->assertEquals(
64            ['{http://sabredav.org/ns}idk'],
65            $pf->get404Properties()
66        );
67
68    }
69
70}
71