2013-10-21 22:46:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Sabre\CalDAV\Notifications;
|
|
|
|
|
|
|
|
use Sabre\CalDAV;
|
|
|
|
|
|
|
|
class NodeTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
|
|
|
|
protected $systemStatus;
|
|
|
|
protected $caldavBackend;
|
|
|
|
|
|
|
|
function getInstance() {
|
|
|
|
|
|
|
|
$principalUri = 'principals/user1';
|
|
|
|
|
2016-05-28 15:46:24 +00:00
|
|
|
$this->systemStatus = new CalDAV\Xml\Notification\SystemStatus(1, '"1"');
|
2013-10-21 22:46:31 +00:00
|
|
|
|
2016-05-11 00:26:44 +00:00
|
|
|
$this->caldavBackend = new CalDAV\Backend\MockSharing([], [], [
|
|
|
|
'principals/user1' => [
|
2013-10-21 22:46:31 +00:00
|
|
|
$this->systemStatus
|
2016-05-11 00:26:44 +00:00
|
|
|
]
|
|
|
|
]);
|
2013-10-21 22:46:31 +00:00
|
|
|
|
|
|
|
$node = new Node($this->caldavBackend, 'principals/user1', $this->systemStatus);
|
|
|
|
return $node;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetId() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
|
|
|
$this->assertEquals($this->systemStatus->getId() . '.xml', $node->getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetEtag() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
|
|
|
$this->assertEquals('"1"', $node->getETag());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetNotificationType() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
|
|
|
$this->assertEquals($this->systemStatus, $node->getNotificationType());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testDelete() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
|
|
|
$node->delete();
|
2016-05-28 15:46:24 +00:00
|
|
|
$this->assertEquals([], $this->caldavBackend->getNotificationsForPrincipal('principals/user1'));
|
2013-10-21 22:46:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetGroup() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
|
|
|
$this->assertNull($node->getGroup());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetACL() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
2016-05-28 15:46:24 +00:00
|
|
|
$expected = [
|
|
|
|
[
|
|
|
|
'privilege' => '{DAV:}all',
|
|
|
|
'principal' => '{DAV:}owner',
|
2013-10-21 22:46:31 +00:00
|
|
|
'protected' => true,
|
2016-05-28 15:46:24 +00:00
|
|
|
],
|
|
|
|
];
|
2013-10-21 22:46:31 +00:00
|
|
|
|
|
|
|
$this->assertEquals($expected, $node->getACL());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-28 15:46:24 +00:00
|
|
|
* @expectedException \Sabre\DAV\Exception\Forbidden
|
2013-10-21 22:46:31 +00:00
|
|
|
*/
|
|
|
|
function testSetACL() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
2016-05-28 15:46:24 +00:00
|
|
|
$node->setACL([]);
|
2013-10-21 22:46:31 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetSupportedPrivilegeSet() {
|
|
|
|
|
|
|
|
$node = $this->getInstance();
|
|
|
|
$this->assertNull($node->getSupportedPrivilegeSet());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|