The birthday_calendar is read-only

This commit is contained in:
Thomas Müller 2016-03-10 12:32:46 +01:00
parent a58e374956
commit 62a36ee884
2 changed files with 13 additions and 7 deletions

View File

@ -22,11 +22,20 @@
namespace OCA\DAV\CalDAV;
use OCA\DAV\DAV\Sharing\IShareable;
use Sabre\CalDAV\Backend\BackendInterface;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\PropPatch;
class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
public function __construct(BackendInterface $caldavBackend, $calendarInfo) {
parent::__construct($caldavBackend, $calendarInfo);
if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {
$this->calendarInfo['{http://sabredav.org/ns}read-only'] = true;
}
}
/**
* Updates the list of shares.
*
@ -100,10 +109,6 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
}
function delete() {
if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {
throw new Forbidden();
}
if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
$principal = 'principal:' . parent::getOwner();
$shares = $this->getShares();

View File

@ -32,7 +32,7 @@ class CalendarTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
$backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
$backend->expects($this->once())->method('updateShares');
$backend->method('getShares')->willReturn([
$backend->expects($this->any())->method('getShares')->willReturn([
['href' => 'principal:user2']
]);
$calendarInfo = [
@ -52,7 +52,7 @@ class CalendarTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
$backend = $this->getMockBuilder('OCA\DAV\CalDAV\CalDavBackend')->disableOriginalConstructor()->getMock();
$backend->expects($this->never())->method('updateShares');
$backend->method('getShares')->willReturn([
$backend->expects($this->any())->method('getShares')->willReturn([
['href' => 'principal:group2']
]);
$calendarInfo = [
@ -90,7 +90,8 @@ class CalendarTest extends TestCase {
$calendarInfo = [
'{http://owncloud.org/ns}owner-principal' => 'user1',
'principaluri' => 'user2',
'id' => 666
'id' => 666,
'uri' => 'default'
];
$c = new Calendar($backend, $calendarInfo);