ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PluginTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\CardDAV;
4
5use Sabre\DAV;
6
8
9 function testConstruct() {
10
11 $this->assertEquals('{' . Plugin::NS_CARDDAV . '}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']);
12
13 $this->assertTrue(in_array('addressbook', $this->plugin->getFeatures()));
14 $this->assertEquals('carddav', $this->plugin->getPluginInfo()['name']);
15
16 }
17
19
20 $this->assertEquals([
21 '{' . Plugin::NS_CARDDAV . '}addressbook-multiget',
22 '{' . Plugin::NS_CARDDAV . '}addressbook-query',
23 ], $this->plugin->getSupportedReportSet('addressbooks/user1/book1'));
24
25 }
26
28
29 $this->assertEquals([
30 ], $this->plugin->getSupportedReportSet(''));
31
32 }
33
35
36 $result = $this->server->getProperties('principals/user1', ['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']);
37
38 $this->assertEquals(1, count($result));
39 $this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']));
40 $this->assertEquals('addressbooks/user1/', $result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']->getHref());
41
42 }
43
45
46 $result = $this->server->getProperties('principals/user1', ['{' . Plugin::NS_CARDDAV . '}directory-gateway']);
47
48 $this->assertEquals(1, count($result));
49 $this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}directory-gateway']));
50 $this->assertEquals(['directory'], $result['{' . Plugin::NS_CARDDAV . '}directory-gateway']->getHrefs());
51
52 }
53
55
56 $this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument(), ''));
57
58 }
59
61
62 $output = '';
63 $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('addressbooks/user1'), &$output]);
64 $this->assertFalse($r);
65
66 $this->assertTrue(!!strpos($output, 'Display name'));
67
68 }
69
71
72 $ns = '{' . Plugin::NS_CARDDAV . '}';
73 $propFind = new DAV\PropFind('addressbooks/user1/book1', [
74 $ns . 'supported-address-data',
75 $ns . 'supported-collation-set',
76 ]);
77 $node = $this->server->tree->getNodeForPath('addressbooks/user1/book1');
78 $this->plugin->propFindEarly($propFind, $node);
79
80 $this->assertInstanceOf(
81 'Sabre\\CardDAV\\Xml\\Property\\SupportedAddressData',
82 $propFind->get($ns . 'supported-address-data')
83 );
84 $this->assertInstanceOf(
85 'Sabre\\CardDAV\\Xml\\Property\\SupportedCollationSet',
86 $propFind->get($ns . 'supported-collation-set')
87 );
88
89
90 }
91
92 function testGetTransform() {
93
94 $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept: application/vcard+json']);
95 $response = new \Sabre\HTTP\ResponseMock();
96 $this->server->invokeMethod($request, $response);
97
98 $this->assertEquals(200, $response->getStatus());
99
100 }
101
102}
$result
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
const NS_CARDDAV
xml namespace for CardDAV elements
Definition: Plugin.php:33
This class holds all the information about a PROPFIND request.
Definition: PropFind.php:11
$r
Definition: example_031.php:79
$response