From 0b02a6d123b2014705998c94ddf3d460948d3eac Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 10 May 2016 17:26:44 -0700 Subject: initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import) --- .../sabre/dav/tests/Sabre/CardDAV/PluginTest.php | 96 ++++++---------------- 1 file changed, 25 insertions(+), 71 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php') diff --git a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php index 297ebf496..9c916350e 100644 --- a/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/CardDAV/PluginTest.php @@ -3,17 +3,16 @@ namespace Sabre\CardDAV; use Sabre\DAV; - -require_once 'Sabre/CardDAV/AbstractPluginTest.php'; +use Sabre\DAV\Xml\Property\Href; 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())); + $this->assertEquals('carddav', $this->plugin->getPluginInfo()['name']); } @@ -43,25 +42,6 @@ class PluginTest extends AbstractPluginTest { } - 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')); @@ -74,76 +54,50 @@ class PluginTest extends AbstractPluginTest { function testReportPassThrough() { - $this->assertNull($this->plugin->report('{DAV:}foo', new \DomDocument())); + $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)); + $r = $this->server->emit('onHTMLActionsPanel', [$this->server->tree->getNodeForPath('addressbooks/user1'), &$output]); $this->assertFalse($r); $this->assertTrue(!!strpos($output,'Display name')); } - function testBrowserPostAction() { + function testAddressbookPluginProperties() { - $r = $this->server->broadcastEvent('onBrowserPostAction', array('addressbooks/user1', 'mkaddressbook', array( - 'name' => 'NEWADDRESSBOOK', - '{DAV:}displayname' => 'foo', - ))); - $this->assertFalse($r); + $ns = '{' . Plugin::NS_CARDDAV . '}'; + $propFind = new DAV\PropFind('addressbooks/user1/book1', [ + $ns . 'supported-address-data', + $ns . 'supported-collation-set', + ]); + $node = $this->server->tree->getNodeForPath('addressbooks/user1/book1'); + $this->plugin->propFindEarly($propFind, $node); - $addressbooks = $this->backend->getAddressBooksforUser('principals/user1'); - $this->assertEquals(2, count($addressbooks)); + $this->assertInstanceOf( + 'Sabre\\CardDAV\\Xml\\Property\\SupportedAddressData', + $propFind->get($ns . 'supported-address-data') + ); + $this->assertInstanceOf( + 'Sabre\\CardDAV\\Xml\\Property\\SupportedCollationSet', + $propFind->get($ns . 'supported-collation-set') + ); - $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() { + function testGetTransform() { - $result = $this->server->updateProperties('addressbooks/user1', array( - '{http://calendarserver.org/ns/}me-card' => new DAV\Property\Href('/addressbooks/user1/book1/vcard2',true), - )); + $request = new \Sabre\HTTP\Request('GET', '/addressbooks/user1/book1/card1', ['Accept: application/vcard+json']); + $response = new \Sabre\HTTP\ResponseMock(); + $this->server->invokeMethod($request, $response); - $this->assertEquals( - array( - 'href' => 'addressbooks/user1', - 200 => array( - '{http://calendarserver.org/ns/}me-card' => null, - ), - ), - $result - ); + $this->assertEquals(200, $response->getStatus()); } - 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 - ); - - } } -- cgit v1.2.3