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([], $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 = [ 69 [ 70 'privilege' => '{DAV:}all', 71 'principal' => '{DAV:}owner', 72 'protected' => true, 73 ], 74 ]; 75 76 $this->assertEquals($expected, $node->getACL()); 77 78 } 79 80 /** 81 * @expectedException \Sabre\DAV\Exception\Forbidden 82 */ 83 function testSetACL() { 84 85 $node = $this->getInstance(); 86 $node->setACL([]); 87 88 } 89 90 function testGetSupportedPrivilegeSet() { 91 92 $node = $this->getInstance(); 93 $this->assertNull($node->getSupportedPrivilegeSet()); 94 95 } 96} 97