Page MenuHomePhabricator

CalendarHomeSubscriptionsTest.php
No OneTemporary

CalendarHomeSubscriptionsTest.php

<?php
namespace Sabre\CalDAV;
use
Sabre\DAV\MkCol,
Sabre\DAVACL;
class CalendarHomeSubscriptionsTest extends \PHPUnit_Framework_TestCase {
protected $backend;
function getInstance() {
$props = [
'{DAV:}displayname' => 'baz',
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/test.ics'),
];
$principal = [
'uri' => 'principals/user1'
];
$this->backend = new Backend\MockSubscriptionSupport([], []);
$this->backend->createSubscription('principals/user1', 'uri', $props);
return new CalendarHome($this->backend, $principal);
}
function testSimple() {
$instance = $this->getInstance();
$this->assertEquals('user1', $instance->getName());
}
function testGetChildren() {
$instance = $this->getInstance();
$children = $instance->getChildren();
$this->assertEquals(1, count($children));
foreach($children as $child) {
if ($child instanceof Subscriptions\Subscription) {
return;
}
}
$this->fail('There were no subscription nodes in the calendar home');
}
function testCreateSubscription() {
$instance = $this->getInstance();
$rt = ['{DAV:}collection', '{http://calendarserver.org/ns/}subscribed'];
$props = [
'{DAV:}displayname' => 'baz',
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/test2.ics'),
];
$instance->createExtendedCollection('sub2', new MkCol($rt, $props));
$children = $instance->getChildren();
$this->assertEquals(2, count($children));
}
/**
* @expectedException \Sabre\DAV\Exception\InvalidResourceType
*/
function testNoSubscriptionSupport() {
$principal = [
'uri' => 'principals/user1'
];
$backend = new Backend\Mock([], []);
$uC = new CalendarHome($backend, $principal);
$rt = ['{DAV:}collection', '{http://calendarserver.org/ns/}subscribed'];
$props = [
'{DAV:}displayname' => 'baz',
'{http://calendarserver.org/ns/}source' => new \Sabre\DAV\Xml\Property\Href('http://example.org/test2.ics'),
];
$uC->createExtendedCollection('sub2', new MkCol($rt, $props));
}
}

File Metadata

Mime Type
text/x-php
Expires
Tue, Dec 24, 11:07 AM (21 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914548
Default Alt Text
CalendarHomeSubscriptionsTest.php (2 KB)

Event Timeline