1<?php 2 3namespace Sabre\CalDAV\Notifications; 4 5use Sabre\CalDAV; 6 7class NodeTest extends \PHPUnit_Framework_TestCase { 8 9 protected $systemStatus; 10 protected $caldavBackend; 11 12 function getInstance() { 13 14 $principalUri = 'principals/user1'; 15 16 $this->systemStatus = new CalDAV\Xml\Notification\SystemStatus(1,'"1"'); 17 18 $this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [ 19 'principals/user1' => [ 20 $this->systemStatus 21 ] 22 ]); 23 24 $node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus); 25 return $node; 26 27 } 28 29 function testGetId() { 30 31 $node = $this->getInstance(); 32 $this->assertEquals($this->systemStatus->getId() . '.xml', $node->getName()); 33 34 } 35 36 function testGetEtag() { 37 38 $node = $this->getInstance(); 39 $this->assertEquals('"1"', $node->getETag()); 40 41 } 42 43 function testGetNotificationType() { 44 45 $node = $this->getInstance(); 46 $this->assertEquals($this->systemStatus, $node->getNotificationType()); 47 48 } 49 50 function testDelete() { 51 52 $node = $this->getInstance(); 53 $node->delete(); 54 $this->assertEquals(array(), $this->caldavBackend->getNotificationsForPrincipal('principals/user1')); 55 56 } 57 58 function testGetGroup() { 59 60 $node = $this->getInstance(); 61 $this->assertNull($node->getGroup()); 62 63 } 64 65 function testGetACL() { 66 67 $node = $this->getInstance(); 68 $expected = array( 69 array( 70 'privilege' => '{DAV:}read', 71 'principal' => 'principals/user1', 72 'protected' => true, 73 ), 74 array( 75 'privilege' => '{DAV:}write', 76 'principal' => 'principals/user1', 77 'protected' => true, 78 ), 79 ); 80 81 $this->assertEquals($expected, $node->getACL()); 82 83 } 84 85 /** 86 * @expectedException Sabre\DAV\Exception\NotImplemented 87 */ 88 function testSetACL() { 89 90 $node = $this->getInstance(); 91 $node->setACL(array()); 92 93 } 94 95 function testGetSupportedPrivilegeSet() { 96 97 $node = $this->getInstance(); 98 $this->assertNull($node->getSupportedPrivilegeSet()); 99 100 } 101} 102