3 class Sabre_CardDAV_CardTest extends PHPUnit_Framework_TestCase {
6 * @var Sabre_CardDAV_Card
10 * @var Sabre_CardDAV_MockBackend
16 $this->backend = new Sabre_CardDAV_Backend_Mock();
17 $this->card = new Sabre_CardDAV_Card(
22 'principaluri' => 'principals/user1',
26 'addressbookid' => 'foo',
35 $result = $this->card->get();
36 $this->assertEquals('card', $result);
41 $this->card = new Sabre_CardDAV_Card(
46 'principaluri' => 'principals/user1',
50 'addressbookid' => 'foo',
53 $result = $this->card->get();
54 $this->assertEquals("BEGIN:VCARD\nVERSION:3.0\nUID:12345\nEND:VCARD", $result);
64 $file = fopen('php://memory','r+');
65 fwrite($file, 'newdata');
67 $this->card->put($file);
68 $result = $this->card->get();
69 $this->assertEquals('newdata', $result);
74 function testDelete() {
76 $this->card->delete();
77 $this->assertEquals(1, count($this->backend->cards['foo']));
81 function testGetContentType() {
83 $this->assertEquals('text/x-vcard; charset=utf-8', $this->card->getContentType());
87 function testGetETag() {
89 $this->assertEquals('"' . md5('card') . '"' , $this->card->getETag());
93 function testGetETag2() {
95 $card = new Sabre_CardDAV_Card(
100 'principaluri' => 'principals/user1',
104 'addressbookid' => 'foo',
105 'carddata' => 'card',
106 'etag' => '"blabla"',
109 $this->assertEquals('"blabla"' , $card->getETag());
113 function testGetLastModified() {
115 $this->assertEquals(null, $this->card->getLastModified());
119 function testGetSize() {
121 $this->assertEquals(4, $this->card->getSize());
122 $this->assertEquals(4, $this->card->getSize());
126 function testGetSize2() {
128 $card = new Sabre_CardDAV_Card(
133 'principaluri' => 'principals/user1',
137 'addressbookid' => 'foo',
138 'etag' => '"blabla"',
142 $this->assertEquals(4, $card->getSize());
146 function testACLMethods() {
148 $this->assertEquals('principals/user1', $this->card->getOwner());
149 $this->assertNull($this->card->getGroup());
150 $this->assertEquals(array(
152 'privilege' => '{DAV:}read',
153 'principal' => 'principals/user1',
157 'privilege' => '{DAV:}write',
158 'principal' => 'principals/user1',
161 ), $this->card->getACL());
166 * @expectedException Sabre_DAV_Exception_MethodNotAllowed
168 function testSetACL() {
170 $this->card->setACL(array());
174 function testGetSupportedPrivilegeSet() {
177 $this->card->getSupportedPrivilegeSet()