Blame view
sources/3rdparty/sabre/dav/tests/Sabre/CardDAV/PluginTest.php
4.4 KB
|
6d9380f96
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
<?php
namespace Sabre\CardDAV;
use Sabre\DAV;
require_once 'Sabre/CardDAV/AbstractPluginTest.php';
class PluginTest extends AbstractPluginTest {
function testConstruct() {
$this->assertEquals('card', $this->server->xmlNamespaces[Plugin::NS_CARDDAV]);
$this->assertEquals('{' . Plugin::NS_CARDDAV . '}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']);
$this->assertTrue(in_array('addressbook', $this->plugin->getFeatures()));
}
function testSupportedReportSet() {
$this->assertEquals(array(
'{' . Plugin::NS_CARDDAV . '}addressbook-multiget',
'{' . Plugin::NS_CARDDAV . '}addressbook-query',
), $this->plugin->getSupportedReportSet('addressbooks/user1/book1'));
}
function testSupportedReportSetEmpty() {
$this->assertEquals(array(
), $this->plugin->getSupportedReportSet(''));
}
function testAddressBookHomeSet() {
$result = $this->server->getProperties('principals/user1', array('{' . Plugin::NS_CARDDAV . '}addressbook-home-set'));
$this->assertEquals(1, count($result));
$this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']));
$this->assertEquals('addressbooks/user1/', $result['{' . Plugin::NS_CARDDAV . '}addressbook-home-set']->getHref());
}
function testMeCardTest() {
$result = $this->server->getProperties(
'addressbooks/user1',
array(
'{http://calendarserver.org/ns/}me-card',
)
);
$this->assertEquals(
array(
'{http://calendarserver.org/ns/}me-card' =>
new DAV\Property\Href('addressbooks/user1/book1/vcard1.vcf')
),
$result
);
}
function testDirectoryGateway() {
$result = $this->server->getProperties('principals/user1', array('{' . Plugin::NS_CARDDAV . '}directory-gateway'));
$this->assertEquals(1, count($result));
$this->assertTrue(isset($result['{' . Plugin::NS_CARDDAV . '}directory-gateway']));
$this->assertEquals(array('directory'), $result['{' . Plugin::NS_CARDDAV . '}directory-gateway']->getHrefs());
}
function testReportPassThrough() {
$this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument()));
}
function testHTMLActionsPanel() {
$output = '';
$r = $this->server->broadcastEvent('onHTMLActionsPanel', array($this->server->tree->getNodeForPath('addressbooks/user1'), &$output));
$this->assertFalse($r);
$this->assertTrue(!!strpos($output,'Display name'));
}
function testBrowserPostAction() {
$r = $this->server->broadcastEvent('onBrowserPostAction', array('addressbooks/user1', 'mkaddressbook', array(
'name' => 'NEWADDRESSBOOK',
'{DAV:}displayname' => 'foo',
)));
$this->assertFalse($r);
$addressbooks = $this->backend->getAddressBooksforUser('principals/user1');
$this->assertEquals(2, count($addressbooks));
$newAddressBook = null;
foreach($addressbooks as $addressbook) {
if ($addressbook['uri'] === 'NEWADDRESSBOOK') {
$newAddressBook = $addressbook;
break;
}
}
if (!$newAddressBook)
$this->fail('Could not find newly created addressbook');
}
function testUpdatePropertiesMeCard() {
$result = $this->server->updateProperties('addressbooks/user1', array(
'{http://calendarserver.org/ns/}me-card' => new DAV\Property\Href('/addressbooks/user1/book1/vcard2',true),
));
$this->assertEquals(
array(
'href' => 'addressbooks/user1',
200 => array(
'{http://calendarserver.org/ns/}me-card' => null,
),
),
$result
);
}
function testUpdatePropertiesMeCardBadValue() {
$result = $this->server->updateProperties('addressbooks/user1', array(
'{http://calendarserver.org/ns/}me-card' => new DAV\Property\HrefList(array()),
));
$this->assertEquals(
array(
'href' => 'addressbooks/user1',
400 => array(
'{http://calendarserver.org/ns/}me-card' => null,
),
),
$result
);
}
}
|