@@ -14,144 +14,144 @@ |
||
| 14 | 14 | |
| 15 | 15 | class CalendarObject extends \Sabre\CalDAV\CalendarObject { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * CalendarObject constructor. |
|
| 19 | - * |
|
| 20 | - * @param CalDavBackend $caldavBackend |
|
| 21 | - * @param IL10N $l10n |
|
| 22 | - * @param array $calendarInfo |
|
| 23 | - * @param array $objectData |
|
| 24 | - */ |
|
| 25 | - public function __construct( |
|
| 26 | - CalDavBackend $caldavBackend, |
|
| 27 | - protected IL10N $l10n, |
|
| 28 | - array $calendarInfo, |
|
| 29 | - array $objectData, |
|
| 30 | - ) { |
|
| 31 | - parent::__construct($caldavBackend, $calendarInfo, $objectData); |
|
| 32 | - |
|
| 33 | - if ($this->isShared()) { |
|
| 34 | - unset($this->objectData['size']); |
|
| 35 | - } |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @inheritdoc |
|
| 40 | - */ |
|
| 41 | - public function get() { |
|
| 42 | - $data = parent::get(); |
|
| 43 | - |
|
| 44 | - if (!$this->isShared()) { |
|
| 45 | - return $data; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - $vObject = Reader::read($data); |
|
| 49 | - |
|
| 50 | - // remove VAlarms if calendar is shared read-only |
|
| 51 | - if (!$this->canWrite()) { |
|
| 52 | - $this->removeVAlarms($vObject); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - // shows as busy if event is declared confidential |
|
| 56 | - if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL |
|
| 57 | - && ($this->isPublic() || !$this->canWrite())) { |
|
| 58 | - $this->createConfidentialObject($vObject); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - return $vObject->serialize(); |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - public function getId(): int { |
|
| 65 | - return (int)$this->objectData['id']; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - protected function isShared() { |
|
| 69 | - if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 70 | - return false; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @param Component\VCalendar $vObject |
|
| 78 | - * @return void |
|
| 79 | - */ |
|
| 80 | - private function createConfidentialObject(Component\VCalendar $vObject): void { |
|
| 81 | - /** @var Component $vElement */ |
|
| 82 | - $vElements = array_filter($vObject->getComponents(), static function ($vElement) { |
|
| 83 | - return $vElement instanceof Component\VEvent || $vElement instanceof Component\VJournal || $vElement instanceof Component\VTodo; |
|
| 84 | - }); |
|
| 85 | - |
|
| 86 | - foreach ($vElements as $vElement) { |
|
| 87 | - if (empty($vElement->select('SUMMARY'))) { |
|
| 88 | - $vElement->add('SUMMARY', $this->l10n->t('Busy')); // This is needed to mask "Untitled Event" events |
|
| 89 | - } |
|
| 90 | - foreach ($vElement->children() as &$property) { |
|
| 91 | - /** @var Property $property */ |
|
| 92 | - switch ($property->name) { |
|
| 93 | - case 'CREATED': |
|
| 94 | - case 'DTSTART': |
|
| 95 | - case 'RRULE': |
|
| 96 | - case 'RECURRENCE-ID': |
|
| 97 | - case 'RDATE': |
|
| 98 | - case 'DURATION': |
|
| 99 | - case 'DTEND': |
|
| 100 | - case 'CLASS': |
|
| 101 | - case 'EXRULE': |
|
| 102 | - case 'EXDATE': |
|
| 103 | - case 'UID': |
|
| 104 | - break; |
|
| 105 | - case 'SUMMARY': |
|
| 106 | - $property->setValue($this->l10n->t('Busy')); |
|
| 107 | - break; |
|
| 108 | - default: |
|
| 109 | - $vElement->__unset($property->name); |
|
| 110 | - unset($property); |
|
| 111 | - break; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @param Component\VCalendar $vObject |
|
| 119 | - * @return void |
|
| 120 | - */ |
|
| 121 | - private function removeVAlarms(Component\VCalendar $vObject) { |
|
| 122 | - $subcomponents = $vObject->getComponents(); |
|
| 123 | - |
|
| 124 | - foreach ($subcomponents as $subcomponent) { |
|
| 125 | - unset($subcomponent->VALARM); |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @return bool |
|
| 131 | - */ |
|
| 132 | - private function canWrite() { |
|
| 133 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
| 134 | - return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
| 135 | - } |
|
| 136 | - return true; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - private function isPublic(): bool { |
|
| 140 | - return $this->calendarInfo['{http://owncloud.org/ns}public'] ?? false; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - public function getCalendarId(): int { |
|
| 144 | - return (int)$this->objectData['calendarid']; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - public function getPrincipalUri(): string { |
|
| 148 | - return $this->calendarInfo['principaluri']; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - public function getOwner(): ?string { |
|
| 152 | - if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 153 | - return $this->calendarInfo['{http://owncloud.org/ns}owner-principal']; |
|
| 154 | - } |
|
| 155 | - return parent::getOwner(); |
|
| 156 | - } |
|
| 17 | + /** |
|
| 18 | + * CalendarObject constructor. |
|
| 19 | + * |
|
| 20 | + * @param CalDavBackend $caldavBackend |
|
| 21 | + * @param IL10N $l10n |
|
| 22 | + * @param array $calendarInfo |
|
| 23 | + * @param array $objectData |
|
| 24 | + */ |
|
| 25 | + public function __construct( |
|
| 26 | + CalDavBackend $caldavBackend, |
|
| 27 | + protected IL10N $l10n, |
|
| 28 | + array $calendarInfo, |
|
| 29 | + array $objectData, |
|
| 30 | + ) { |
|
| 31 | + parent::__construct($caldavBackend, $calendarInfo, $objectData); |
|
| 32 | + |
|
| 33 | + if ($this->isShared()) { |
|
| 34 | + unset($this->objectData['size']); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @inheritdoc |
|
| 40 | + */ |
|
| 41 | + public function get() { |
|
| 42 | + $data = parent::get(); |
|
| 43 | + |
|
| 44 | + if (!$this->isShared()) { |
|
| 45 | + return $data; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + $vObject = Reader::read($data); |
|
| 49 | + |
|
| 50 | + // remove VAlarms if calendar is shared read-only |
|
| 51 | + if (!$this->canWrite()) { |
|
| 52 | + $this->removeVAlarms($vObject); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + // shows as busy if event is declared confidential |
|
| 56 | + if ($this->objectData['classification'] === CalDavBackend::CLASSIFICATION_CONFIDENTIAL |
|
| 57 | + && ($this->isPublic() || !$this->canWrite())) { |
|
| 58 | + $this->createConfidentialObject($vObject); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + return $vObject->serialize(); |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + public function getId(): int { |
|
| 65 | + return (int)$this->objectData['id']; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + protected function isShared() { |
|
| 69 | + if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 70 | + return false; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param Component\VCalendar $vObject |
|
| 78 | + * @return void |
|
| 79 | + */ |
|
| 80 | + private function createConfidentialObject(Component\VCalendar $vObject): void { |
|
| 81 | + /** @var Component $vElement */ |
|
| 82 | + $vElements = array_filter($vObject->getComponents(), static function ($vElement) { |
|
| 83 | + return $vElement instanceof Component\VEvent || $vElement instanceof Component\VJournal || $vElement instanceof Component\VTodo; |
|
| 84 | + }); |
|
| 85 | + |
|
| 86 | + foreach ($vElements as $vElement) { |
|
| 87 | + if (empty($vElement->select('SUMMARY'))) { |
|
| 88 | + $vElement->add('SUMMARY', $this->l10n->t('Busy')); // This is needed to mask "Untitled Event" events |
|
| 89 | + } |
|
| 90 | + foreach ($vElement->children() as &$property) { |
|
| 91 | + /** @var Property $property */ |
|
| 92 | + switch ($property->name) { |
|
| 93 | + case 'CREATED': |
|
| 94 | + case 'DTSTART': |
|
| 95 | + case 'RRULE': |
|
| 96 | + case 'RECURRENCE-ID': |
|
| 97 | + case 'RDATE': |
|
| 98 | + case 'DURATION': |
|
| 99 | + case 'DTEND': |
|
| 100 | + case 'CLASS': |
|
| 101 | + case 'EXRULE': |
|
| 102 | + case 'EXDATE': |
|
| 103 | + case 'UID': |
|
| 104 | + break; |
|
| 105 | + case 'SUMMARY': |
|
| 106 | + $property->setValue($this->l10n->t('Busy')); |
|
| 107 | + break; |
|
| 108 | + default: |
|
| 109 | + $vElement->__unset($property->name); |
|
| 110 | + unset($property); |
|
| 111 | + break; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @param Component\VCalendar $vObject |
|
| 119 | + * @return void |
|
| 120 | + */ |
|
| 121 | + private function removeVAlarms(Component\VCalendar $vObject) { |
|
| 122 | + $subcomponents = $vObject->getComponents(); |
|
| 123 | + |
|
| 124 | + foreach ($subcomponents as $subcomponent) { |
|
| 125 | + unset($subcomponent->VALARM); |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @return bool |
|
| 131 | + */ |
|
| 132 | + private function canWrite() { |
|
| 133 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}read-only'])) { |
|
| 134 | + return !$this->calendarInfo['{http://owncloud.org/ns}read-only']; |
|
| 135 | + } |
|
| 136 | + return true; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + private function isPublic(): bool { |
|
| 140 | + return $this->calendarInfo['{http://owncloud.org/ns}public'] ?? false; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + public function getCalendarId(): int { |
|
| 144 | + return (int)$this->objectData['calendarid']; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + public function getPrincipalUri(): string { |
|
| 148 | + return $this->calendarInfo['principaluri']; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + public function getOwner(): ?string { |
|
| 152 | + if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { |
|
| 153 | + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal']; |
|
| 154 | + } |
|
| 155 | + return parent::getOwner(); |
|
| 156 | + } |
|
| 157 | 157 | } |
@@ -16,51 +16,51 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | class PublicCalendarTest extends CalendarTest { |
| 18 | 18 | |
| 19 | - #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 20 | - public function testPrivateClassification(int $expectedChildren, bool $isShared): void { |
|
| 21 | - $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 22 | - $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL]; |
|
| 23 | - $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 24 | - |
|
| 25 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 26 | - $backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock(); |
|
| 27 | - $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 28 | - $calObject0, $calObject1, $calObject2 |
|
| 29 | - ]); |
|
| 30 | - $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 31 | - ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 32 | - ->willReturn([ |
|
| 33 | - $calObject0, $calObject1, $calObject2 |
|
| 34 | - ]); |
|
| 35 | - $backend->expects($this->any())->method('getCalendarObject') |
|
| 36 | - ->willReturn($calObject2)->with(666, 'event-2'); |
|
| 37 | - $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 38 | - |
|
| 39 | - $calendarInfo = [ |
|
| 40 | - '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 41 | - 'principaluri' => 'user2', |
|
| 42 | - 'id' => 666, |
|
| 43 | - 'uri' => 'cal', |
|
| 44 | - ]; |
|
| 45 | - /** @var IConfig&MockObject $config */ |
|
| 46 | - $config = $this->createMock(IConfig::class); |
|
| 47 | - /** @var LoggerInterface&MockObject $logger */ |
|
| 48 | - $logger = $this->createMock(LoggerInterface::class); |
|
| 49 | - $c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger); |
|
| 50 | - $children = $c->getChildren(); |
|
| 51 | - $this->assertCount(2, $children); |
|
| 52 | - $children = $c->getMultipleChildren(['event-0', 'event-1', 'event-2']); |
|
| 53 | - $this->assertCount(2, $children); |
|
| 54 | - |
|
| 55 | - $this->assertFalse($c->childExists('event-2')); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 59 | - public function testConfidentialClassification(int $expectedChildren, bool $isShared): void { |
|
| 60 | - $start = '20160609'; |
|
| 61 | - $end = '20160610'; |
|
| 62 | - |
|
| 63 | - $calData = <<<EOD |
|
| 19 | + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 20 | + public function testPrivateClassification(int $expectedChildren, bool $isShared): void { |
|
| 21 | + $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 22 | + $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL]; |
|
| 23 | + $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 24 | + |
|
| 25 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 26 | + $backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock(); |
|
| 27 | + $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 28 | + $calObject0, $calObject1, $calObject2 |
|
| 29 | + ]); |
|
| 30 | + $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 31 | + ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 32 | + ->willReturn([ |
|
| 33 | + $calObject0, $calObject1, $calObject2 |
|
| 34 | + ]); |
|
| 35 | + $backend->expects($this->any())->method('getCalendarObject') |
|
| 36 | + ->willReturn($calObject2)->with(666, 'event-2'); |
|
| 37 | + $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 38 | + |
|
| 39 | + $calendarInfo = [ |
|
| 40 | + '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 41 | + 'principaluri' => 'user2', |
|
| 42 | + 'id' => 666, |
|
| 43 | + 'uri' => 'cal', |
|
| 44 | + ]; |
|
| 45 | + /** @var IConfig&MockObject $config */ |
|
| 46 | + $config = $this->createMock(IConfig::class); |
|
| 47 | + /** @var LoggerInterface&MockObject $logger */ |
|
| 48 | + $logger = $this->createMock(LoggerInterface::class); |
|
| 49 | + $c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger); |
|
| 50 | + $children = $c->getChildren(); |
|
| 51 | + $this->assertCount(2, $children); |
|
| 52 | + $children = $c->getMultipleChildren(['event-0', 'event-1', 'event-2']); |
|
| 53 | + $this->assertCount(2, $children); |
|
| 54 | + |
|
| 55 | + $this->assertFalse($c->childExists('event-2')); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 59 | + public function testConfidentialClassification(int $expectedChildren, bool $isShared): void { |
|
| 60 | + $start = '20160609'; |
|
| 61 | + $end = '20160610'; |
|
| 62 | + |
|
| 63 | + $calData = <<<EOD |
|
| 64 | 64 | BEGIN:VCALENDAR |
| 65 | 65 | PRODID:-//ownCloud calendar v1.2.2 |
| 66 | 66 | BEGIN:VEVENT |
@@ -102,51 +102,51 @@ discard block |
||
| 102 | 102 | END:VCALENDAR |
| 103 | 103 | EOD; |
| 104 | 104 | |
| 105 | - $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 106 | - $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'calendardata' => $calData]; |
|
| 107 | - $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 108 | - |
|
| 109 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 110 | - $backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock(); |
|
| 111 | - $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 112 | - $calObject0, $calObject1, $calObject2 |
|
| 113 | - ]); |
|
| 114 | - $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 115 | - ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 116 | - ->willReturn([ |
|
| 117 | - $calObject0, $calObject1, $calObject2 |
|
| 118 | - ]); |
|
| 119 | - $backend->expects($this->any())->method('getCalendarObject') |
|
| 120 | - ->willReturn($calObject1)->with(666, 'event-1'); |
|
| 121 | - $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 122 | - |
|
| 123 | - $calendarInfo = [ |
|
| 124 | - '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 125 | - 'principaluri' => 'user2', |
|
| 126 | - 'id' => 666, |
|
| 127 | - 'uri' => 'cal', |
|
| 128 | - '{http://owncloud.org/ns}public' => true, |
|
| 129 | - ]; |
|
| 130 | - /** @var IConfig&MockObject $config */ |
|
| 131 | - $config = $this->createMock(IConfig::class); |
|
| 132 | - /** @var LoggerInterface&MockObject $logger */ |
|
| 133 | - $logger = $this->createMock(LoggerInterface::class); |
|
| 134 | - $c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger); |
|
| 135 | - |
|
| 136 | - $this->assertCount(2, $c->getChildren()); |
|
| 137 | - |
|
| 138 | - // test private event |
|
| 139 | - $privateEvent = $c->getChild('event-1'); |
|
| 140 | - $calData = $privateEvent->get(); |
|
| 141 | - $event = Reader::read($calData); |
|
| 142 | - |
|
| 143 | - $this->assertEquals($start, $event->VEVENT->DTSTART->getValue()); |
|
| 144 | - $this->assertEquals($end, $event->VEVENT->DTEND->getValue()); |
|
| 145 | - |
|
| 146 | - $this->assertEquals('Busy', $event->VEVENT->SUMMARY->getValue()); |
|
| 147 | - $this->assertArrayNotHasKey('ATTENDEE', $event->VEVENT); |
|
| 148 | - $this->assertArrayNotHasKey('LOCATION', $event->VEVENT); |
|
| 149 | - $this->assertArrayNotHasKey('DESCRIPTION', $event->VEVENT); |
|
| 150 | - $this->assertArrayNotHasKey('ORGANIZER', $event->VEVENT); |
|
| 151 | - } |
|
| 105 | + $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 106 | + $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'calendardata' => $calData]; |
|
| 107 | + $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 108 | + |
|
| 109 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 110 | + $backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock(); |
|
| 111 | + $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 112 | + $calObject0, $calObject1, $calObject2 |
|
| 113 | + ]); |
|
| 114 | + $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 115 | + ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 116 | + ->willReturn([ |
|
| 117 | + $calObject0, $calObject1, $calObject2 |
|
| 118 | + ]); |
|
| 119 | + $backend->expects($this->any())->method('getCalendarObject') |
|
| 120 | + ->willReturn($calObject1)->with(666, 'event-1'); |
|
| 121 | + $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 122 | + |
|
| 123 | + $calendarInfo = [ |
|
| 124 | + '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 125 | + 'principaluri' => 'user2', |
|
| 126 | + 'id' => 666, |
|
| 127 | + 'uri' => 'cal', |
|
| 128 | + '{http://owncloud.org/ns}public' => true, |
|
| 129 | + ]; |
|
| 130 | + /** @var IConfig&MockObject $config */ |
|
| 131 | + $config = $this->createMock(IConfig::class); |
|
| 132 | + /** @var LoggerInterface&MockObject $logger */ |
|
| 133 | + $logger = $this->createMock(LoggerInterface::class); |
|
| 134 | + $c = new PublicCalendar($backend, $calendarInfo, $this->l10n, $config, $logger); |
|
| 135 | + |
|
| 136 | + $this->assertCount(2, $c->getChildren()); |
|
| 137 | + |
|
| 138 | + // test private event |
|
| 139 | + $privateEvent = $c->getChild('event-1'); |
|
| 140 | + $calData = $privateEvent->get(); |
|
| 141 | + $event = Reader::read($calData); |
|
| 142 | + |
|
| 143 | + $this->assertEquals($start, $event->VEVENT->DTSTART->getValue()); |
|
| 144 | + $this->assertEquals($end, $event->VEVENT->DTEND->getValue()); |
|
| 145 | + |
|
| 146 | + $this->assertEquals('Busy', $event->VEVENT->SUMMARY->getValue()); |
|
| 147 | + $this->assertArrayNotHasKey('ATTENDEE', $event->VEVENT); |
|
| 148 | + $this->assertArrayNotHasKey('LOCATION', $event->VEVENT); |
|
| 149 | + $this->assertArrayNotHasKey('DESCRIPTION', $event->VEVENT); |
|
| 150 | + $this->assertArrayNotHasKey('ORGANIZER', $event->VEVENT); |
|
| 151 | + } |
|
| 152 | 152 | } |
@@ -20,296 +20,296 @@ discard block |
||
| 20 | 20 | use Test\TestCase; |
| 21 | 21 | |
| 22 | 22 | class CalendarTest extends TestCase { |
| 23 | - protected IL10N&MockObject $l10n; |
|
| 24 | - protected IConfig&MockObject $config; |
|
| 25 | - protected LoggerInterface&MockObject $logger; |
|
| 26 | - |
|
| 27 | - protected function setUp(): void { |
|
| 28 | - parent::setUp(); |
|
| 29 | - $this->l10n = $this->createMock(IL10N::class); |
|
| 30 | - $this->config = $this->createMock(IConfig::class); |
|
| 31 | - $this->logger = $this->createMock(LoggerInterface::class); |
|
| 32 | - $this->l10n |
|
| 33 | - ->expects($this->any()) |
|
| 34 | - ->method('t') |
|
| 35 | - ->willReturnCallback(function ($text, $parameters = []) { |
|
| 36 | - return vsprintf($text, $parameters); |
|
| 37 | - }); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - public function testDelete(): void { |
|
| 41 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 42 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 43 | - $backend->expects($this->never()) |
|
| 44 | - ->method('updateShares'); |
|
| 45 | - $backend->expects($this->once()) |
|
| 46 | - ->method('unshare'); |
|
| 47 | - |
|
| 48 | - $calendarInfo = [ |
|
| 49 | - '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 50 | - 'principaluri' => 'user2', |
|
| 51 | - 'id' => 666, |
|
| 52 | - 'uri' => 'cal', |
|
| 53 | - ]; |
|
| 54 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 55 | - $c->delete(); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - public function testDeleteFromGroup(): void { |
|
| 60 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 61 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 62 | - $backend->expects($this->never()) |
|
| 63 | - ->method('updateShares'); |
|
| 64 | - $backend->expects($this->once()) |
|
| 65 | - ->method('unshare'); |
|
| 66 | - |
|
| 67 | - $calendarInfo = [ |
|
| 68 | - '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 69 | - 'principaluri' => 'user2', |
|
| 70 | - 'id' => 666, |
|
| 71 | - 'uri' => 'cal', |
|
| 72 | - ]; |
|
| 73 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 74 | - $c->delete(); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function testDeleteOwn(): void { |
|
| 78 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 79 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 80 | - $backend->expects($this->never())->method('updateShares'); |
|
| 81 | - $backend->expects($this->never())->method('getShares'); |
|
| 82 | - |
|
| 83 | - $this->config->expects($this->never())->method('setUserValue'); |
|
| 84 | - |
|
| 85 | - $backend->expects($this->once())->method('deleteCalendar') |
|
| 86 | - ->with(666); |
|
| 87 | - |
|
| 88 | - $calendarInfo = [ |
|
| 89 | - '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 90 | - 'principaluri' => 'user1', |
|
| 91 | - 'id' => 666, |
|
| 92 | - 'uri' => 'cal', |
|
| 93 | - ]; |
|
| 94 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 95 | - $c->delete(); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - public function testDeleteBirthdayCalendar(): void { |
|
| 99 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 100 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 101 | - $backend->expects($this->once())->method('deleteCalendar') |
|
| 102 | - ->with(666); |
|
| 103 | - |
|
| 104 | - $this->config->expects($this->once()) |
|
| 105 | - ->method('setUserValue') |
|
| 106 | - ->with('user1', 'dav', 'generateBirthdayCalendar', 'no'); |
|
| 107 | - |
|
| 108 | - $calendarInfo = [ |
|
| 109 | - '{http://owncloud.org/ns}owner-principal' => 'principals/users/user1', |
|
| 110 | - 'principaluri' => 'principals/users/user1', |
|
| 111 | - 'id' => 666, |
|
| 112 | - 'uri' => 'contact_birthdays', |
|
| 113 | - '{DAV:}displayname' => 'Test', |
|
| 114 | - ]; |
|
| 115 | - |
|
| 116 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 117 | - $c->delete(); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - public static function dataPropPatch(): array { |
|
| 121 | - return [ |
|
| 122 | - ['user1', 'user2', [], true], |
|
| 123 | - ['user1', 'user2', [ |
|
| 124 | - '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 125 | - ], true], |
|
| 126 | - ['user1', 'user2', [ |
|
| 127 | - '{DAV:}displayname' => true, |
|
| 128 | - ], true], |
|
| 129 | - ['user1', 'user2', [ |
|
| 130 | - '{DAV:}displayname' => true, |
|
| 131 | - '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 132 | - ], true], |
|
| 133 | - ['user1', 'user1', [], false], |
|
| 134 | - ['user1', 'user1', [ |
|
| 135 | - '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 136 | - ], false], |
|
| 137 | - ['user1', 'user1', [ |
|
| 138 | - '{DAV:}displayname' => true, |
|
| 139 | - ], false], |
|
| 140 | - ['user1', 'user1', [ |
|
| 141 | - '{DAV:}displayname' => true, |
|
| 142 | - '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 143 | - ], false], |
|
| 144 | - ]; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - #[\PHPUnit\Framework\Attributes\DataProvider('dataPropPatch')] |
|
| 148 | - public function testPropPatch(string $ownerPrincipal, string $principalUri, array $mutations, bool $shared): void { |
|
| 149 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 150 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 151 | - $calendarInfo = [ |
|
| 152 | - '{http://owncloud.org/ns}owner-principal' => $ownerPrincipal, |
|
| 153 | - 'principaluri' => $principalUri, |
|
| 154 | - 'id' => 666, |
|
| 155 | - 'uri' => 'default' |
|
| 156 | - ]; |
|
| 157 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 158 | - $propPatch = new PropPatch($mutations); |
|
| 159 | - |
|
| 160 | - if (!$shared) { |
|
| 161 | - $backend->expects($this->once()) |
|
| 162 | - ->method('updateCalendar') |
|
| 163 | - ->with(666, $propPatch); |
|
| 164 | - } |
|
| 165 | - $c->propPatch($propPatch); |
|
| 166 | - $this->addToAssertionCount(1); |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - #[\PHPUnit\Framework\Attributes\DataProvider('providesReadOnlyInfo')] |
|
| 170 | - public function testAcl($expectsWrite, $readOnlyValue, $hasOwnerSet, $uri = 'default'): void { |
|
| 171 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 172 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 173 | - $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 174 | - $calendarInfo = [ |
|
| 175 | - 'principaluri' => 'user2', |
|
| 176 | - 'id' => 666, |
|
| 177 | - 'uri' => $uri |
|
| 178 | - ]; |
|
| 179 | - $calendarInfo['{DAV:}displayname'] = 'Test'; |
|
| 180 | - if (!is_null($readOnlyValue)) { |
|
| 181 | - $calendarInfo['{http://owncloud.org/ns}read-only'] = $readOnlyValue; |
|
| 182 | - } |
|
| 183 | - if ($hasOwnerSet) { |
|
| 184 | - $calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1'; |
|
| 185 | - } |
|
| 186 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 187 | - $acl = $c->getACL(); |
|
| 188 | - $childAcl = $c->getChildACL(); |
|
| 189 | - |
|
| 190 | - $expectedAcl = [[ |
|
| 191 | - 'privilege' => '{DAV:}read', |
|
| 192 | - 'principal' => $hasOwnerSet ? 'user1' : 'user2', |
|
| 193 | - 'protected' => true |
|
| 194 | - ], [ |
|
| 195 | - 'privilege' => '{DAV:}read', |
|
| 196 | - 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-write', |
|
| 197 | - 'protected' => true, |
|
| 198 | - ], [ |
|
| 199 | - 'privilege' => '{DAV:}read', |
|
| 200 | - 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-read', |
|
| 201 | - 'protected' => true, |
|
| 202 | - ]]; |
|
| 203 | - if ($uri === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
| 204 | - $expectedAcl[] = [ |
|
| 205 | - 'privilege' => '{DAV:}write-properties', |
|
| 206 | - 'principal' => $hasOwnerSet ? 'user1' : 'user2', |
|
| 207 | - 'protected' => true |
|
| 208 | - ]; |
|
| 209 | - $expectedAcl[] = [ |
|
| 210 | - 'privilege' => '{DAV:}write-properties', |
|
| 211 | - 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-write', |
|
| 212 | - 'protected' => true |
|
| 213 | - ]; |
|
| 214 | - } else { |
|
| 215 | - $expectedAcl[] = [ |
|
| 216 | - 'privilege' => '{DAV:}write', |
|
| 217 | - 'principal' => $hasOwnerSet ? 'user1' : 'user2', |
|
| 218 | - 'protected' => true |
|
| 219 | - ]; |
|
| 220 | - $expectedAcl[] = [ |
|
| 221 | - 'privilege' => '{DAV:}write', |
|
| 222 | - 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-write', |
|
| 223 | - 'protected' => true |
|
| 224 | - ]; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - $expectedAcl[] = [ |
|
| 228 | - 'privilege' => '{DAV:}write-properties', |
|
| 229 | - 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-read', |
|
| 230 | - 'protected' => true |
|
| 231 | - ]; |
|
| 232 | - |
|
| 233 | - if ($hasOwnerSet) { |
|
| 234 | - $expectedAcl[] = [ |
|
| 235 | - 'privilege' => '{DAV:}read', |
|
| 236 | - 'principal' => 'user2', |
|
| 237 | - 'protected' => true |
|
| 238 | - ]; |
|
| 239 | - if ($expectsWrite) { |
|
| 240 | - $expectedAcl[] = [ |
|
| 241 | - 'privilege' => '{DAV:}write', |
|
| 242 | - 'principal' => 'user2', |
|
| 243 | - 'protected' => true |
|
| 244 | - ]; |
|
| 245 | - } else { |
|
| 246 | - $expectedAcl[] = [ |
|
| 247 | - 'privilege' => '{DAV:}write-properties', |
|
| 248 | - 'principal' => 'user2', |
|
| 249 | - 'protected' => true |
|
| 250 | - ]; |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - $this->assertEquals($expectedAcl, $acl); |
|
| 254 | - $this->assertEquals($expectedAcl, $childAcl); |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - public static function providesReadOnlyInfo(): array { |
|
| 258 | - return [ |
|
| 259 | - 'read-only property not set' => [true, null, true], |
|
| 260 | - 'read-only property is false' => [true, false, true], |
|
| 261 | - 'read-only property is true' => [false, true, true], |
|
| 262 | - 'read-only property not set and no owner' => [true, null, false], |
|
| 263 | - 'read-only property is false and no owner' => [true, false, false], |
|
| 264 | - 'read-only property is true and no owner' => [false, true, false], |
|
| 265 | - 'birthday calendar' => [false, false, false, BirthdayService::BIRTHDAY_CALENDAR_URI] |
|
| 266 | - ]; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 270 | - public function testPrivateClassification(int $expectedChildren, bool $isShared): void { |
|
| 271 | - $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 272 | - $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL]; |
|
| 273 | - $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 274 | - |
|
| 275 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 276 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 277 | - $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 278 | - $calObject0, $calObject1, $calObject2 |
|
| 279 | - ]); |
|
| 280 | - $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 281 | - ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 282 | - ->willReturn([ |
|
| 283 | - $calObject0, $calObject1, $calObject2 |
|
| 284 | - ]); |
|
| 285 | - $backend->expects($this->any())->method('getCalendarObject') |
|
| 286 | - ->willReturn($calObject2)->with(666, 'event-2'); |
|
| 287 | - $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 288 | - |
|
| 289 | - $calendarInfo = [ |
|
| 290 | - 'principaluri' => 'user2', |
|
| 291 | - 'id' => 666, |
|
| 292 | - 'uri' => 'cal', |
|
| 293 | - ]; |
|
| 294 | - |
|
| 295 | - if ($isShared) { |
|
| 296 | - $calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1'; |
|
| 297 | - } |
|
| 298 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 299 | - $children = $c->getChildren(); |
|
| 300 | - $this->assertCount($expectedChildren, $children); |
|
| 301 | - $children = $c->getMultipleChildren(['event-0', 'event-1', 'event-2']); |
|
| 302 | - $this->assertCount($expectedChildren, $children); |
|
| 303 | - |
|
| 304 | - $this->assertEquals(!$isShared, $c->childExists('event-2')); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 308 | - public function testConfidentialClassification(int $expectedChildren, bool $isShared): void { |
|
| 309 | - $start = '20160609'; |
|
| 310 | - $end = '20160610'; |
|
| 311 | - |
|
| 312 | - $calData = <<<EOD |
|
| 23 | + protected IL10N&MockObject $l10n; |
|
| 24 | + protected IConfig&MockObject $config; |
|
| 25 | + protected LoggerInterface&MockObject $logger; |
|
| 26 | + |
|
| 27 | + protected function setUp(): void { |
|
| 28 | + parent::setUp(); |
|
| 29 | + $this->l10n = $this->createMock(IL10N::class); |
|
| 30 | + $this->config = $this->createMock(IConfig::class); |
|
| 31 | + $this->logger = $this->createMock(LoggerInterface::class); |
|
| 32 | + $this->l10n |
|
| 33 | + ->expects($this->any()) |
|
| 34 | + ->method('t') |
|
| 35 | + ->willReturnCallback(function ($text, $parameters = []) { |
|
| 36 | + return vsprintf($text, $parameters); |
|
| 37 | + }); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + public function testDelete(): void { |
|
| 41 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 42 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 43 | + $backend->expects($this->never()) |
|
| 44 | + ->method('updateShares'); |
|
| 45 | + $backend->expects($this->once()) |
|
| 46 | + ->method('unshare'); |
|
| 47 | + |
|
| 48 | + $calendarInfo = [ |
|
| 49 | + '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 50 | + 'principaluri' => 'user2', |
|
| 51 | + 'id' => 666, |
|
| 52 | + 'uri' => 'cal', |
|
| 53 | + ]; |
|
| 54 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 55 | + $c->delete(); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + public function testDeleteFromGroup(): void { |
|
| 60 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 61 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 62 | + $backend->expects($this->never()) |
|
| 63 | + ->method('updateShares'); |
|
| 64 | + $backend->expects($this->once()) |
|
| 65 | + ->method('unshare'); |
|
| 66 | + |
|
| 67 | + $calendarInfo = [ |
|
| 68 | + '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 69 | + 'principaluri' => 'user2', |
|
| 70 | + 'id' => 666, |
|
| 71 | + 'uri' => 'cal', |
|
| 72 | + ]; |
|
| 73 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 74 | + $c->delete(); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + public function testDeleteOwn(): void { |
|
| 78 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 79 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 80 | + $backend->expects($this->never())->method('updateShares'); |
|
| 81 | + $backend->expects($this->never())->method('getShares'); |
|
| 82 | + |
|
| 83 | + $this->config->expects($this->never())->method('setUserValue'); |
|
| 84 | + |
|
| 85 | + $backend->expects($this->once())->method('deleteCalendar') |
|
| 86 | + ->with(666); |
|
| 87 | + |
|
| 88 | + $calendarInfo = [ |
|
| 89 | + '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 90 | + 'principaluri' => 'user1', |
|
| 91 | + 'id' => 666, |
|
| 92 | + 'uri' => 'cal', |
|
| 93 | + ]; |
|
| 94 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 95 | + $c->delete(); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + public function testDeleteBirthdayCalendar(): void { |
|
| 99 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 100 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 101 | + $backend->expects($this->once())->method('deleteCalendar') |
|
| 102 | + ->with(666); |
|
| 103 | + |
|
| 104 | + $this->config->expects($this->once()) |
|
| 105 | + ->method('setUserValue') |
|
| 106 | + ->with('user1', 'dav', 'generateBirthdayCalendar', 'no'); |
|
| 107 | + |
|
| 108 | + $calendarInfo = [ |
|
| 109 | + '{http://owncloud.org/ns}owner-principal' => 'principals/users/user1', |
|
| 110 | + 'principaluri' => 'principals/users/user1', |
|
| 111 | + 'id' => 666, |
|
| 112 | + 'uri' => 'contact_birthdays', |
|
| 113 | + '{DAV:}displayname' => 'Test', |
|
| 114 | + ]; |
|
| 115 | + |
|
| 116 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 117 | + $c->delete(); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + public static function dataPropPatch(): array { |
|
| 121 | + return [ |
|
| 122 | + ['user1', 'user2', [], true], |
|
| 123 | + ['user1', 'user2', [ |
|
| 124 | + '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 125 | + ], true], |
|
| 126 | + ['user1', 'user2', [ |
|
| 127 | + '{DAV:}displayname' => true, |
|
| 128 | + ], true], |
|
| 129 | + ['user1', 'user2', [ |
|
| 130 | + '{DAV:}displayname' => true, |
|
| 131 | + '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 132 | + ], true], |
|
| 133 | + ['user1', 'user1', [], false], |
|
| 134 | + ['user1', 'user1', [ |
|
| 135 | + '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 136 | + ], false], |
|
| 137 | + ['user1', 'user1', [ |
|
| 138 | + '{DAV:}displayname' => true, |
|
| 139 | + ], false], |
|
| 140 | + ['user1', 'user1', [ |
|
| 141 | + '{DAV:}displayname' => true, |
|
| 142 | + '{http://owncloud.org/ns}calendar-enabled' => true, |
|
| 143 | + ], false], |
|
| 144 | + ]; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + #[\PHPUnit\Framework\Attributes\DataProvider('dataPropPatch')] |
|
| 148 | + public function testPropPatch(string $ownerPrincipal, string $principalUri, array $mutations, bool $shared): void { |
|
| 149 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 150 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 151 | + $calendarInfo = [ |
|
| 152 | + '{http://owncloud.org/ns}owner-principal' => $ownerPrincipal, |
|
| 153 | + 'principaluri' => $principalUri, |
|
| 154 | + 'id' => 666, |
|
| 155 | + 'uri' => 'default' |
|
| 156 | + ]; |
|
| 157 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 158 | + $propPatch = new PropPatch($mutations); |
|
| 159 | + |
|
| 160 | + if (!$shared) { |
|
| 161 | + $backend->expects($this->once()) |
|
| 162 | + ->method('updateCalendar') |
|
| 163 | + ->with(666, $propPatch); |
|
| 164 | + } |
|
| 165 | + $c->propPatch($propPatch); |
|
| 166 | + $this->addToAssertionCount(1); |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + #[\PHPUnit\Framework\Attributes\DataProvider('providesReadOnlyInfo')] |
|
| 170 | + public function testAcl($expectsWrite, $readOnlyValue, $hasOwnerSet, $uri = 'default'): void { |
|
| 171 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 172 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 173 | + $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 174 | + $calendarInfo = [ |
|
| 175 | + 'principaluri' => 'user2', |
|
| 176 | + 'id' => 666, |
|
| 177 | + 'uri' => $uri |
|
| 178 | + ]; |
|
| 179 | + $calendarInfo['{DAV:}displayname'] = 'Test'; |
|
| 180 | + if (!is_null($readOnlyValue)) { |
|
| 181 | + $calendarInfo['{http://owncloud.org/ns}read-only'] = $readOnlyValue; |
|
| 182 | + } |
|
| 183 | + if ($hasOwnerSet) { |
|
| 184 | + $calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1'; |
|
| 185 | + } |
|
| 186 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 187 | + $acl = $c->getACL(); |
|
| 188 | + $childAcl = $c->getChildACL(); |
|
| 189 | + |
|
| 190 | + $expectedAcl = [[ |
|
| 191 | + 'privilege' => '{DAV:}read', |
|
| 192 | + 'principal' => $hasOwnerSet ? 'user1' : 'user2', |
|
| 193 | + 'protected' => true |
|
| 194 | + ], [ |
|
| 195 | + 'privilege' => '{DAV:}read', |
|
| 196 | + 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-write', |
|
| 197 | + 'protected' => true, |
|
| 198 | + ], [ |
|
| 199 | + 'privilege' => '{DAV:}read', |
|
| 200 | + 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-read', |
|
| 201 | + 'protected' => true, |
|
| 202 | + ]]; |
|
| 203 | + if ($uri === BirthdayService::BIRTHDAY_CALENDAR_URI) { |
|
| 204 | + $expectedAcl[] = [ |
|
| 205 | + 'privilege' => '{DAV:}write-properties', |
|
| 206 | + 'principal' => $hasOwnerSet ? 'user1' : 'user2', |
|
| 207 | + 'protected' => true |
|
| 208 | + ]; |
|
| 209 | + $expectedAcl[] = [ |
|
| 210 | + 'privilege' => '{DAV:}write-properties', |
|
| 211 | + 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-write', |
|
| 212 | + 'protected' => true |
|
| 213 | + ]; |
|
| 214 | + } else { |
|
| 215 | + $expectedAcl[] = [ |
|
| 216 | + 'privilege' => '{DAV:}write', |
|
| 217 | + 'principal' => $hasOwnerSet ? 'user1' : 'user2', |
|
| 218 | + 'protected' => true |
|
| 219 | + ]; |
|
| 220 | + $expectedAcl[] = [ |
|
| 221 | + 'privilege' => '{DAV:}write', |
|
| 222 | + 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-write', |
|
| 223 | + 'protected' => true |
|
| 224 | + ]; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + $expectedAcl[] = [ |
|
| 228 | + 'privilege' => '{DAV:}write-properties', |
|
| 229 | + 'principal' => ($hasOwnerSet ? 'user1' : 'user2') . '/calendar-proxy-read', |
|
| 230 | + 'protected' => true |
|
| 231 | + ]; |
|
| 232 | + |
|
| 233 | + if ($hasOwnerSet) { |
|
| 234 | + $expectedAcl[] = [ |
|
| 235 | + 'privilege' => '{DAV:}read', |
|
| 236 | + 'principal' => 'user2', |
|
| 237 | + 'protected' => true |
|
| 238 | + ]; |
|
| 239 | + if ($expectsWrite) { |
|
| 240 | + $expectedAcl[] = [ |
|
| 241 | + 'privilege' => '{DAV:}write', |
|
| 242 | + 'principal' => 'user2', |
|
| 243 | + 'protected' => true |
|
| 244 | + ]; |
|
| 245 | + } else { |
|
| 246 | + $expectedAcl[] = [ |
|
| 247 | + 'privilege' => '{DAV:}write-properties', |
|
| 248 | + 'principal' => 'user2', |
|
| 249 | + 'protected' => true |
|
| 250 | + ]; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + $this->assertEquals($expectedAcl, $acl); |
|
| 254 | + $this->assertEquals($expectedAcl, $childAcl); |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + public static function providesReadOnlyInfo(): array { |
|
| 258 | + return [ |
|
| 259 | + 'read-only property not set' => [true, null, true], |
|
| 260 | + 'read-only property is false' => [true, false, true], |
|
| 261 | + 'read-only property is true' => [false, true, true], |
|
| 262 | + 'read-only property not set and no owner' => [true, null, false], |
|
| 263 | + 'read-only property is false and no owner' => [true, false, false], |
|
| 264 | + 'read-only property is true and no owner' => [false, true, false], |
|
| 265 | + 'birthday calendar' => [false, false, false, BirthdayService::BIRTHDAY_CALENDAR_URI] |
|
| 266 | + ]; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 270 | + public function testPrivateClassification(int $expectedChildren, bool $isShared): void { |
|
| 271 | + $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 272 | + $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL]; |
|
| 273 | + $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 274 | + |
|
| 275 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 276 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 277 | + $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 278 | + $calObject0, $calObject1, $calObject2 |
|
| 279 | + ]); |
|
| 280 | + $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 281 | + ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 282 | + ->willReturn([ |
|
| 283 | + $calObject0, $calObject1, $calObject2 |
|
| 284 | + ]); |
|
| 285 | + $backend->expects($this->any())->method('getCalendarObject') |
|
| 286 | + ->willReturn($calObject2)->with(666, 'event-2'); |
|
| 287 | + $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 288 | + |
|
| 289 | + $calendarInfo = [ |
|
| 290 | + 'principaluri' => 'user2', |
|
| 291 | + 'id' => 666, |
|
| 292 | + 'uri' => 'cal', |
|
| 293 | + ]; |
|
| 294 | + |
|
| 295 | + if ($isShared) { |
|
| 296 | + $calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1'; |
|
| 297 | + } |
|
| 298 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 299 | + $children = $c->getChildren(); |
|
| 300 | + $this->assertCount($expectedChildren, $children); |
|
| 301 | + $children = $c->getMultipleChildren(['event-0', 'event-1', 'event-2']); |
|
| 302 | + $this->assertCount($expectedChildren, $children); |
|
| 303 | + |
|
| 304 | + $this->assertEquals(!$isShared, $c->childExists('event-2')); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + #[\PHPUnit\Framework\Attributes\DataProvider('providesConfidentialClassificationData')] |
|
| 308 | + public function testConfidentialClassification(int $expectedChildren, bool $isShared): void { |
|
| 309 | + $start = '20160609'; |
|
| 310 | + $end = '20160610'; |
|
| 311 | + |
|
| 312 | + $calData = <<<EOD |
|
| 313 | 313 | BEGIN:VCALENDAR |
| 314 | 314 | PRODID:-//ownCloud calendar v1.2.2 |
| 315 | 315 | BEGIN:VEVENT |
@@ -351,88 +351,88 @@ discard block |
||
| 351 | 351 | END:VCALENDAR |
| 352 | 352 | EOD; |
| 353 | 353 | |
| 354 | - $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 355 | - $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'calendardata' => $calData]; |
|
| 356 | - $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 357 | - |
|
| 358 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 359 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 360 | - $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 361 | - $calObject0, $calObject1, $calObject2 |
|
| 362 | - ]); |
|
| 363 | - $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 364 | - ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 365 | - ->willReturn([ |
|
| 366 | - $calObject0, $calObject1, $calObject2 |
|
| 367 | - ]); |
|
| 368 | - $backend->expects($this->any())->method('getCalendarObject') |
|
| 369 | - ->willReturn($calObject1)->with(666, 'event-1'); |
|
| 370 | - $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 371 | - |
|
| 372 | - $calendarInfo = [ |
|
| 373 | - '{http://owncloud.org/ns}owner-principal' => $isShared ? 'user1' : 'user2', |
|
| 374 | - 'principaluri' => 'user2', |
|
| 375 | - 'id' => 666, |
|
| 376 | - 'uri' => 'cal', |
|
| 377 | - ]; |
|
| 378 | - |
|
| 379 | - if ($isShared) { |
|
| 380 | - $calendarInfo['{http://owncloud.org/ns}read-only'] = true; |
|
| 381 | - } |
|
| 382 | - $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 383 | - |
|
| 384 | - $this->assertCount($expectedChildren, $c->getChildren()); |
|
| 385 | - |
|
| 386 | - // test private event |
|
| 387 | - $privateEvent = $c->getChild('event-1'); |
|
| 388 | - $calData = $privateEvent->get(); |
|
| 389 | - $event = Reader::read($calData); |
|
| 390 | - |
|
| 391 | - $this->assertEquals($start, $event->VEVENT->DTSTART->getValue()); |
|
| 392 | - $this->assertEquals($end, $event->VEVENT->DTEND->getValue()); |
|
| 393 | - |
|
| 394 | - if ($isShared) { |
|
| 395 | - $this->assertEquals('Busy', $event->VEVENT->SUMMARY->getValue()); |
|
| 396 | - $this->assertArrayNotHasKey('ATTENDEE', $event->VEVENT); |
|
| 397 | - $this->assertArrayNotHasKey('LOCATION', $event->VEVENT); |
|
| 398 | - $this->assertArrayNotHasKey('DESCRIPTION', $event->VEVENT); |
|
| 399 | - $this->assertArrayNotHasKey('ORGANIZER', $event->VEVENT); |
|
| 400 | - } else { |
|
| 401 | - $this->assertEquals('Test Event', $event->VEVENT->SUMMARY->getValue()); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // Test l10n |
|
| 405 | - $l10n = $this->createMock(IL10N::class); |
|
| 406 | - if ($isShared) { |
|
| 407 | - $l10n->expects($this->once()) |
|
| 408 | - ->method('t') |
|
| 409 | - ->with('Busy') |
|
| 410 | - ->willReturn('Translated busy'); |
|
| 411 | - } else { |
|
| 412 | - $l10n->expects($this->never()) |
|
| 413 | - ->method('t'); |
|
| 414 | - } |
|
| 415 | - $c = new Calendar($backend, $calendarInfo, $l10n, $this->config, $this->logger); |
|
| 416 | - |
|
| 417 | - $calData = $c->getChild('event-1')->get(); |
|
| 418 | - $event = Reader::read($calData); |
|
| 419 | - |
|
| 420 | - if ($isShared) { |
|
| 421 | - $this->assertEquals('Translated busy', $event->VEVENT->SUMMARY->getValue()); |
|
| 422 | - } else { |
|
| 423 | - $this->assertEquals('Test Event', $event->VEVENT->SUMMARY->getValue()); |
|
| 424 | - } |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - public static function providesConfidentialClassificationData(): array { |
|
| 428 | - return [ |
|
| 429 | - [3, false], |
|
| 430 | - [2, true] |
|
| 431 | - ]; |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - public function testRemoveVAlarms(): void { |
|
| 435 | - $publicObjectData = <<<EOD |
|
| 354 | + $calObject0 = ['uri' => 'event-0', 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC]; |
|
| 355 | + $calObject1 = ['uri' => 'event-1', 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, 'calendardata' => $calData]; |
|
| 356 | + $calObject2 = ['uri' => 'event-2', 'classification' => CalDavBackend::CLASSIFICATION_PRIVATE]; |
|
| 357 | + |
|
| 358 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 359 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 360 | + $backend->expects($this->any())->method('getCalendarObjects')->willReturn([ |
|
| 361 | + $calObject0, $calObject1, $calObject2 |
|
| 362 | + ]); |
|
| 363 | + $backend->expects($this->any())->method('getMultipleCalendarObjects') |
|
| 364 | + ->with(666, ['event-0', 'event-1', 'event-2']) |
|
| 365 | + ->willReturn([ |
|
| 366 | + $calObject0, $calObject1, $calObject2 |
|
| 367 | + ]); |
|
| 368 | + $backend->expects($this->any())->method('getCalendarObject') |
|
| 369 | + ->willReturn($calObject1)->with(666, 'event-1'); |
|
| 370 | + $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1); |
|
| 371 | + |
|
| 372 | + $calendarInfo = [ |
|
| 373 | + '{http://owncloud.org/ns}owner-principal' => $isShared ? 'user1' : 'user2', |
|
| 374 | + 'principaluri' => 'user2', |
|
| 375 | + 'id' => 666, |
|
| 376 | + 'uri' => 'cal', |
|
| 377 | + ]; |
|
| 378 | + |
|
| 379 | + if ($isShared) { |
|
| 380 | + $calendarInfo['{http://owncloud.org/ns}read-only'] = true; |
|
| 381 | + } |
|
| 382 | + $c = new Calendar($backend, $calendarInfo, $this->l10n, $this->config, $this->logger); |
|
| 383 | + |
|
| 384 | + $this->assertCount($expectedChildren, $c->getChildren()); |
|
| 385 | + |
|
| 386 | + // test private event |
|
| 387 | + $privateEvent = $c->getChild('event-1'); |
|
| 388 | + $calData = $privateEvent->get(); |
|
| 389 | + $event = Reader::read($calData); |
|
| 390 | + |
|
| 391 | + $this->assertEquals($start, $event->VEVENT->DTSTART->getValue()); |
|
| 392 | + $this->assertEquals($end, $event->VEVENT->DTEND->getValue()); |
|
| 393 | + |
|
| 394 | + if ($isShared) { |
|
| 395 | + $this->assertEquals('Busy', $event->VEVENT->SUMMARY->getValue()); |
|
| 396 | + $this->assertArrayNotHasKey('ATTENDEE', $event->VEVENT); |
|
| 397 | + $this->assertArrayNotHasKey('LOCATION', $event->VEVENT); |
|
| 398 | + $this->assertArrayNotHasKey('DESCRIPTION', $event->VEVENT); |
|
| 399 | + $this->assertArrayNotHasKey('ORGANIZER', $event->VEVENT); |
|
| 400 | + } else { |
|
| 401 | + $this->assertEquals('Test Event', $event->VEVENT->SUMMARY->getValue()); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + // Test l10n |
|
| 405 | + $l10n = $this->createMock(IL10N::class); |
|
| 406 | + if ($isShared) { |
|
| 407 | + $l10n->expects($this->once()) |
|
| 408 | + ->method('t') |
|
| 409 | + ->with('Busy') |
|
| 410 | + ->willReturn('Translated busy'); |
|
| 411 | + } else { |
|
| 412 | + $l10n->expects($this->never()) |
|
| 413 | + ->method('t'); |
|
| 414 | + } |
|
| 415 | + $c = new Calendar($backend, $calendarInfo, $l10n, $this->config, $this->logger); |
|
| 416 | + |
|
| 417 | + $calData = $c->getChild('event-1')->get(); |
|
| 418 | + $event = Reader::read($calData); |
|
| 419 | + |
|
| 420 | + if ($isShared) { |
|
| 421 | + $this->assertEquals('Translated busy', $event->VEVENT->SUMMARY->getValue()); |
|
| 422 | + } else { |
|
| 423 | + $this->assertEquals('Test Event', $event->VEVENT->SUMMARY->getValue()); |
|
| 424 | + } |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + public static function providesConfidentialClassificationData(): array { |
|
| 428 | + return [ |
|
| 429 | + [3, false], |
|
| 430 | + [2, true] |
|
| 431 | + ]; |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + public function testRemoveVAlarms(): void { |
|
| 435 | + $publicObjectData = <<<EOD |
|
| 436 | 436 | BEGIN:VCALENDAR |
| 437 | 437 | VERSION:2.0 |
| 438 | 438 | PRODID:-//Nextcloud calendar v1.5.6 |
@@ -456,7 +456,7 @@ discard block |
||
| 456 | 456 | |
| 457 | 457 | EOD; |
| 458 | 458 | |
| 459 | - $confidentialObjectData = <<<EOD |
|
| 459 | + $confidentialObjectData = <<<EOD |
|
| 460 | 460 | BEGIN:VCALENDAR |
| 461 | 461 | VERSION:2.0 |
| 462 | 462 | PRODID:-//Nextcloud calendar v1.5.6 |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | |
| 481 | 481 | EOD; |
| 482 | 482 | |
| 483 | - $publicObjectDataWithoutVAlarm = <<<EOD |
|
| 483 | + $publicObjectDataWithoutVAlarm = <<<EOD |
|
| 484 | 484 | BEGIN:VCALENDAR |
| 485 | 485 | VERSION:2.0 |
| 486 | 486 | PRODID:-//Nextcloud calendar v1.5.6 |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | |
| 501 | 501 | EOD; |
| 502 | 502 | |
| 503 | - $confidentialObjectCleaned = <<<EOD |
|
| 503 | + $confidentialObjectCleaned = <<<EOD |
|
| 504 | 504 | BEGIN:VCALENDAR |
| 505 | 505 | VERSION:2.0 |
| 506 | 506 | PRODID:-//Nextcloud calendar v1.5.6 |
@@ -519,94 +519,94 @@ discard block |
||
| 519 | 519 | |
| 520 | 520 | |
| 521 | 521 | |
| 522 | - $publicObject = ['uri' => 'event-0', |
|
| 523 | - 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC, |
|
| 524 | - 'calendardata' => $publicObjectData]; |
|
| 525 | - |
|
| 526 | - $confidentialObject = ['uri' => 'event-1', |
|
| 527 | - 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, |
|
| 528 | - 'calendardata' => $confidentialObjectData]; |
|
| 529 | - |
|
| 530 | - /** @var CalDavBackend&MockObject $backend */ |
|
| 531 | - $backend = $this->createMock(CalDavBackend::class); |
|
| 532 | - $backend->expects($this->any()) |
|
| 533 | - ->method('getCalendarObjects') |
|
| 534 | - ->willReturn([$publicObject, $confidentialObject]); |
|
| 535 | - |
|
| 536 | - $backend->expects($this->any()) |
|
| 537 | - ->method('getMultipleCalendarObjects') |
|
| 538 | - ->with(666, ['event-0', 'event-1']) |
|
| 539 | - ->willReturn([$publicObject, $confidentialObject]); |
|
| 540 | - |
|
| 541 | - $backend->expects($this->any()) |
|
| 542 | - ->method('getCalendarObject') |
|
| 543 | - ->willReturnCallback(function ($cId, $uri) use ($publicObject, $confidentialObject) { |
|
| 544 | - switch ($uri) { |
|
| 545 | - case 'event-0': |
|
| 546 | - return $publicObject; |
|
| 547 | - |
|
| 548 | - case 'event-1': |
|
| 549 | - return $confidentialObject; |
|
| 550 | - |
|
| 551 | - default: |
|
| 552 | - throw new \Exception('unexpected uri'); |
|
| 553 | - } |
|
| 554 | - }); |
|
| 555 | - |
|
| 556 | - $backend->expects($this->any()) |
|
| 557 | - ->method('applyShareAcl') |
|
| 558 | - ->willReturnArgument(1); |
|
| 559 | - |
|
| 560 | - $calendarInfoOwner = [ |
|
| 561 | - '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 562 | - 'principaluri' => 'user1', |
|
| 563 | - 'id' => 666, |
|
| 564 | - 'uri' => 'cal', |
|
| 565 | - ]; |
|
| 566 | - $calendarInfoSharedRW = [ |
|
| 567 | - '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 568 | - 'principaluri' => 'user2', |
|
| 569 | - 'id' => 666, |
|
| 570 | - 'uri' => 'cal', |
|
| 571 | - ]; |
|
| 572 | - $calendarInfoSharedRO = [ |
|
| 573 | - '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 574 | - '{http://owncloud.org/ns}read-only' => true, |
|
| 575 | - 'principaluri' => 'user2', |
|
| 576 | - 'id' => 666, |
|
| 577 | - 'uri' => 'cal', |
|
| 578 | - ]; |
|
| 579 | - |
|
| 580 | - $ownerCalendar = new Calendar($backend, $calendarInfoOwner, $this->l10n, $this->config, $this->logger); |
|
| 581 | - $rwCalendar = new Calendar($backend, $calendarInfoSharedRW, $this->l10n, $this->config, $this->logger); |
|
| 582 | - $roCalendar = new Calendar($backend, $calendarInfoSharedRO, $this->l10n, $this->config, $this->logger); |
|
| 583 | - |
|
| 584 | - $this->assertCount(2, $ownerCalendar->getChildren()); |
|
| 585 | - $this->assertCount(2, $rwCalendar->getChildren()); |
|
| 586 | - $this->assertCount(2, $roCalendar->getChildren()); |
|
| 587 | - |
|
| 588 | - // calendar data shall not be altered for the owner |
|
| 589 | - $this->assertEquals($publicObjectData, $ownerCalendar->getChild('event-0')->get()); |
|
| 590 | - $this->assertEquals($confidentialObjectData, $ownerCalendar->getChild('event-1')->get()); |
|
| 591 | - |
|
| 592 | - // valarms shall not be removed for read-write shares |
|
| 593 | - $this->assertEquals( |
|
| 594 | - $this->fixLinebreak($publicObjectData), |
|
| 595 | - $this->fixLinebreak($rwCalendar->getChild('event-0')->get())); |
|
| 596 | - $this->assertEquals( |
|
| 597 | - $this->fixLinebreak($confidentialObjectData), |
|
| 598 | - $this->fixLinebreak($rwCalendar->getChild('event-1')->get())); |
|
| 599 | - |
|
| 600 | - // valarms shall be removed for read-only shares |
|
| 601 | - $this->assertEquals( |
|
| 602 | - $this->fixLinebreak($publicObjectDataWithoutVAlarm), |
|
| 603 | - $this->fixLinebreak($roCalendar->getChild('event-0')->get())); |
|
| 604 | - $this->assertEquals( |
|
| 605 | - $this->fixLinebreak($confidentialObjectCleaned), |
|
| 606 | - $this->fixLinebreak($roCalendar->getChild('event-1')->get())); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - private function fixLinebreak(string $str): string { |
|
| 610 | - return preg_replace('~(*BSR_ANYCRLF)\R~', "\r\n", $str); |
|
| 611 | - } |
|
| 522 | + $publicObject = ['uri' => 'event-0', |
|
| 523 | + 'classification' => CalDavBackend::CLASSIFICATION_PUBLIC, |
|
| 524 | + 'calendardata' => $publicObjectData]; |
|
| 525 | + |
|
| 526 | + $confidentialObject = ['uri' => 'event-1', |
|
| 527 | + 'classification' => CalDavBackend::CLASSIFICATION_CONFIDENTIAL, |
|
| 528 | + 'calendardata' => $confidentialObjectData]; |
|
| 529 | + |
|
| 530 | + /** @var CalDavBackend&MockObject $backend */ |
|
| 531 | + $backend = $this->createMock(CalDavBackend::class); |
|
| 532 | + $backend->expects($this->any()) |
|
| 533 | + ->method('getCalendarObjects') |
|
| 534 | + ->willReturn([$publicObject, $confidentialObject]); |
|
| 535 | + |
|
| 536 | + $backend->expects($this->any()) |
|
| 537 | + ->method('getMultipleCalendarObjects') |
|
| 538 | + ->with(666, ['event-0', 'event-1']) |
|
| 539 | + ->willReturn([$publicObject, $confidentialObject]); |
|
| 540 | + |
|
| 541 | + $backend->expects($this->any()) |
|
| 542 | + ->method('getCalendarObject') |
|
| 543 | + ->willReturnCallback(function ($cId, $uri) use ($publicObject, $confidentialObject) { |
|
| 544 | + switch ($uri) { |
|
| 545 | + case 'event-0': |
|
| 546 | + return $publicObject; |
|
| 547 | + |
|
| 548 | + case 'event-1': |
|
| 549 | + return $confidentialObject; |
|
| 550 | + |
|
| 551 | + default: |
|
| 552 | + throw new \Exception('unexpected uri'); |
|
| 553 | + } |
|
| 554 | + }); |
|
| 555 | + |
|
| 556 | + $backend->expects($this->any()) |
|
| 557 | + ->method('applyShareAcl') |
|
| 558 | + ->willReturnArgument(1); |
|
| 559 | + |
|
| 560 | + $calendarInfoOwner = [ |
|
| 561 | + '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 562 | + 'principaluri' => 'user1', |
|
| 563 | + 'id' => 666, |
|
| 564 | + 'uri' => 'cal', |
|
| 565 | + ]; |
|
| 566 | + $calendarInfoSharedRW = [ |
|
| 567 | + '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 568 | + 'principaluri' => 'user2', |
|
| 569 | + 'id' => 666, |
|
| 570 | + 'uri' => 'cal', |
|
| 571 | + ]; |
|
| 572 | + $calendarInfoSharedRO = [ |
|
| 573 | + '{http://owncloud.org/ns}owner-principal' => 'user1', |
|
| 574 | + '{http://owncloud.org/ns}read-only' => true, |
|
| 575 | + 'principaluri' => 'user2', |
|
| 576 | + 'id' => 666, |
|
| 577 | + 'uri' => 'cal', |
|
| 578 | + ]; |
|
| 579 | + |
|
| 580 | + $ownerCalendar = new Calendar($backend, $calendarInfoOwner, $this->l10n, $this->config, $this->logger); |
|
| 581 | + $rwCalendar = new Calendar($backend, $calendarInfoSharedRW, $this->l10n, $this->config, $this->logger); |
|
| 582 | + $roCalendar = new Calendar($backend, $calendarInfoSharedRO, $this->l10n, $this->config, $this->logger); |
|
| 583 | + |
|
| 584 | + $this->assertCount(2, $ownerCalendar->getChildren()); |
|
| 585 | + $this->assertCount(2, $rwCalendar->getChildren()); |
|
| 586 | + $this->assertCount(2, $roCalendar->getChildren()); |
|
| 587 | + |
|
| 588 | + // calendar data shall not be altered for the owner |
|
| 589 | + $this->assertEquals($publicObjectData, $ownerCalendar->getChild('event-0')->get()); |
|
| 590 | + $this->assertEquals($confidentialObjectData, $ownerCalendar->getChild('event-1')->get()); |
|
| 591 | + |
|
| 592 | + // valarms shall not be removed for read-write shares |
|
| 593 | + $this->assertEquals( |
|
| 594 | + $this->fixLinebreak($publicObjectData), |
|
| 595 | + $this->fixLinebreak($rwCalendar->getChild('event-0')->get())); |
|
| 596 | + $this->assertEquals( |
|
| 597 | + $this->fixLinebreak($confidentialObjectData), |
|
| 598 | + $this->fixLinebreak($rwCalendar->getChild('event-1')->get())); |
|
| 599 | + |
|
| 600 | + // valarms shall be removed for read-only shares |
|
| 601 | + $this->assertEquals( |
|
| 602 | + $this->fixLinebreak($publicObjectDataWithoutVAlarm), |
|
| 603 | + $this->fixLinebreak($roCalendar->getChild('event-0')->get())); |
|
| 604 | + $this->assertEquals( |
|
| 605 | + $this->fixLinebreak($confidentialObjectCleaned), |
|
| 606 | + $this->fixLinebreak($roCalendar->getChild('event-1')->get())); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + private function fixLinebreak(string $str): string { |
|
| 610 | + return preg_replace('~(*BSR_ANYCRLF)\R~', "\r\n", $str); |
|
| 611 | + } |
|
| 612 | 612 | } |
@@ -20,54 +20,54 @@ discard block |
||
| 20 | 20 | use Test\TestCase; |
| 21 | 21 | |
| 22 | 22 | class PublicCalendarObjectTest extends TestCase { |
| 23 | - private readonly CalDavBackend&MockObject $calDavBackend; |
|
| 24 | - private readonly IL10N&MockObject $l10n; |
|
| 23 | + private readonly CalDavBackend&MockObject $calDavBackend; |
|
| 24 | + private readonly IL10N&MockObject $l10n; |
|
| 25 | 25 | |
| 26 | - protected function setUp(): void { |
|
| 27 | - parent::setUp(); |
|
| 26 | + protected function setUp(): void { |
|
| 27 | + parent::setUp(); |
|
| 28 | 28 | |
| 29 | - $this->calDavBackend = $this->createMock(CalDavBackend::class); |
|
| 30 | - $this->l10n = $this->createMock(IL10N::class); |
|
| 29 | + $this->calDavBackend = $this->createMock(CalDavBackend::class); |
|
| 30 | + $this->l10n = $this->createMock(IL10N::class); |
|
| 31 | 31 | |
| 32 | - $this->l10n->method('t') |
|
| 33 | - ->willReturnArgument(0); |
|
| 34 | - } |
|
| 32 | + $this->l10n->method('t') |
|
| 33 | + ->willReturnArgument(0); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public static function provideConfidentialObjectData(): array { |
|
| 37 | - // For some reason, the CalDavBackend always sets read-only to false. Hence, we test for |
|
| 38 | - // both cases as the property should not matter anyway. |
|
| 39 | - // Ref \OCA\DAV\CalDAV\CalDavBackend::getPublicCalendars (approximately in line 538) |
|
| 40 | - return [ |
|
| 41 | - [ |
|
| 42 | - [ |
|
| 43 | - '{http://owncloud.org/ns}read-only' => true, |
|
| 44 | - '{http://owncloud.org/ns}public' => true, |
|
| 45 | - ], |
|
| 46 | - ], |
|
| 47 | - [ |
|
| 48 | - [ |
|
| 49 | - '{http://owncloud.org/ns}read-only' => false, |
|
| 50 | - '{http://owncloud.org/ns}public' => true, |
|
| 51 | - ], |
|
| 52 | - ], |
|
| 53 | - [ |
|
| 54 | - [ |
|
| 55 | - '{http://owncloud.org/ns}read-only' => 1, |
|
| 56 | - '{http://owncloud.org/ns}public' => true, |
|
| 57 | - ], |
|
| 58 | - ], |
|
| 59 | - [ |
|
| 60 | - [ |
|
| 61 | - '{http://owncloud.org/ns}read-only' => 0, |
|
| 62 | - '{http://owncloud.org/ns}public' => true, |
|
| 63 | - ], |
|
| 64 | - ], |
|
| 65 | - ]; |
|
| 66 | - } |
|
| 36 | + public static function provideConfidentialObjectData(): array { |
|
| 37 | + // For some reason, the CalDavBackend always sets read-only to false. Hence, we test for |
|
| 38 | + // both cases as the property should not matter anyway. |
|
| 39 | + // Ref \OCA\DAV\CalDAV\CalDavBackend::getPublicCalendars (approximately in line 538) |
|
| 40 | + return [ |
|
| 41 | + [ |
|
| 42 | + [ |
|
| 43 | + '{http://owncloud.org/ns}read-only' => true, |
|
| 44 | + '{http://owncloud.org/ns}public' => true, |
|
| 45 | + ], |
|
| 46 | + ], |
|
| 47 | + [ |
|
| 48 | + [ |
|
| 49 | + '{http://owncloud.org/ns}read-only' => false, |
|
| 50 | + '{http://owncloud.org/ns}public' => true, |
|
| 51 | + ], |
|
| 52 | + ], |
|
| 53 | + [ |
|
| 54 | + [ |
|
| 55 | + '{http://owncloud.org/ns}read-only' => 1, |
|
| 56 | + '{http://owncloud.org/ns}public' => true, |
|
| 57 | + ], |
|
| 58 | + ], |
|
| 59 | + [ |
|
| 60 | + [ |
|
| 61 | + '{http://owncloud.org/ns}read-only' => 0, |
|
| 62 | + '{http://owncloud.org/ns}public' => true, |
|
| 63 | + ], |
|
| 64 | + ], |
|
| 65 | + ]; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - #[DataProvider('provideConfidentialObjectData')] |
|
| 69 | - public function testGetWithConfidentialObject(array $calendarInfo): void { |
|
| 70 | - $ics = <<<EOF |
|
| 68 | + #[DataProvider('provideConfidentialObjectData')] |
|
| 69 | + public function testGetWithConfidentialObject(array $calendarInfo): void { |
|
| 70 | + $ics = <<<EOF |
|
| 71 | 71 | BEGIN:VCALENDAR |
| 72 | 72 | CALSCALE:GREGORIAN |
| 73 | 73 | VERSION:2.0 |
@@ -89,26 +89,26 @@ discard block |
||
| 89 | 89 | END:VCALENDAR |
| 90 | 90 | EOF; |
| 91 | 91 | |
| 92 | - $calendarObject = new PublicCalendarObject( |
|
| 93 | - $this->calDavBackend, |
|
| 94 | - $this->l10n, |
|
| 95 | - $calendarInfo, |
|
| 96 | - [ |
|
| 97 | - 'uri' => 'a0f55f1f-4f0e-4db8-a54b-1e8b53846591.ics', |
|
| 98 | - 'calendardata' => $ics, |
|
| 99 | - 'classification' => 2, // CalDavBackend::CLASSIFICATION_CONFIDENTIAL |
|
| 100 | - ], |
|
| 101 | - ); |
|
| 92 | + $calendarObject = new PublicCalendarObject( |
|
| 93 | + $this->calDavBackend, |
|
| 94 | + $this->l10n, |
|
| 95 | + $calendarInfo, |
|
| 96 | + [ |
|
| 97 | + 'uri' => 'a0f55f1f-4f0e-4db8-a54b-1e8b53846591.ics', |
|
| 98 | + 'calendardata' => $ics, |
|
| 99 | + 'classification' => 2, // CalDavBackend::CLASSIFICATION_CONFIDENTIAL |
|
| 100 | + ], |
|
| 101 | + ); |
|
| 102 | 102 | |
| 103 | - $actualIcs = $calendarObject->get(); |
|
| 104 | - $vObject = VObjectReader::read($actualIcs); |
|
| 103 | + $actualIcs = $calendarObject->get(); |
|
| 104 | + $vObject = VObjectReader::read($actualIcs); |
|
| 105 | 105 | |
| 106 | - $this->assertInstanceOf(VCalendar::class, $vObject); |
|
| 107 | - $vEvent = $vObject->getBaseComponent('VEVENT'); |
|
| 108 | - $this->assertInstanceOf(VEvent::class, $vEvent); |
|
| 106 | + $this->assertInstanceOf(VCalendar::class, $vObject); |
|
| 107 | + $vEvent = $vObject->getBaseComponent('VEVENT'); |
|
| 108 | + $this->assertInstanceOf(VEvent::class, $vEvent); |
|
| 109 | 109 | |
| 110 | - $this->assertEquals('Busy', $vEvent->SUMMARY?->getValue()); |
|
| 111 | - $this->assertNull($vEvent->DESCRIPTION); |
|
| 112 | - $this->assertNull($vEvent->LOCATION); |
|
| 113 | - } |
|
| 110 | + $this->assertEquals('Busy', $vEvent->SUMMARY?->getValue()); |
|
| 111 | + $this->assertNull($vEvent->DESCRIPTION); |
|
| 112 | + $this->assertNull($vEvent->LOCATION); |
|
| 113 | + } |
|
| 114 | 114 | } |
@@ -20,71 +20,71 @@ discard block |
||
| 20 | 20 | use Test\TestCase; |
| 21 | 21 | |
| 22 | 22 | class CalendarObjectTest extends TestCase { |
| 23 | - private readonly CalDavBackend&MockObject $calDavBackend; |
|
| 24 | - private readonly IL10N&MockObject $l10n; |
|
| 23 | + private readonly CalDavBackend&MockObject $calDavBackend; |
|
| 24 | + private readonly IL10N&MockObject $l10n; |
|
| 25 | 25 | |
| 26 | - protected function setUp(): void { |
|
| 27 | - parent::setUp(); |
|
| 26 | + protected function setUp(): void { |
|
| 27 | + parent::setUp(); |
|
| 28 | 28 | |
| 29 | - $this->calDavBackend = $this->createMock(CalDavBackend::class); |
|
| 30 | - $this->l10n = $this->createMock(IL10N::class); |
|
| 29 | + $this->calDavBackend = $this->createMock(CalDavBackend::class); |
|
| 30 | + $this->l10n = $this->createMock(IL10N::class); |
|
| 31 | 31 | |
| 32 | - $this->l10n->method('t') |
|
| 33 | - ->willReturnArgument(0); |
|
| 34 | - } |
|
| 32 | + $this->l10n->method('t') |
|
| 33 | + ->willReturnArgument(0); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - public static function provideConfidentialObjectData(): array { |
|
| 37 | - return [ |
|
| 38 | - // Shared writable |
|
| 39 | - [ |
|
| 40 | - false, |
|
| 41 | - [ |
|
| 42 | - 'principaluri' => 'user1', |
|
| 43 | - '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 44 | - ], |
|
| 45 | - ], |
|
| 46 | - [ |
|
| 47 | - false, |
|
| 48 | - [ |
|
| 49 | - 'principaluri' => 'user1', |
|
| 50 | - '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 51 | - '{http://owncloud.org/ns}read-only' => 0, |
|
| 52 | - ], |
|
| 53 | - ], |
|
| 54 | - [ |
|
| 55 | - false, |
|
| 56 | - [ |
|
| 57 | - 'principaluri' => 'user1', |
|
| 58 | - '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 59 | - '{http://owncloud.org/ns}read-only' => false, |
|
| 60 | - ], |
|
| 61 | - ], |
|
| 62 | - // Shared read-only |
|
| 63 | - [ |
|
| 64 | - true, |
|
| 65 | - [ |
|
| 66 | - 'principaluri' => 'user1', |
|
| 67 | - '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 68 | - '{http://owncloud.org/ns}read-only' => 1, |
|
| 69 | - ], |
|
| 70 | - ], |
|
| 71 | - [ |
|
| 72 | - true, |
|
| 73 | - [ |
|
| 74 | - 'principaluri' => 'user1', |
|
| 75 | - '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 76 | - '{http://owncloud.org/ns}read-only' => true, |
|
| 77 | - ], |
|
| 78 | - ], |
|
| 79 | - ]; |
|
| 80 | - } |
|
| 36 | + public static function provideConfidentialObjectData(): array { |
|
| 37 | + return [ |
|
| 38 | + // Shared writable |
|
| 39 | + [ |
|
| 40 | + false, |
|
| 41 | + [ |
|
| 42 | + 'principaluri' => 'user1', |
|
| 43 | + '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 44 | + ], |
|
| 45 | + ], |
|
| 46 | + [ |
|
| 47 | + false, |
|
| 48 | + [ |
|
| 49 | + 'principaluri' => 'user1', |
|
| 50 | + '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 51 | + '{http://owncloud.org/ns}read-only' => 0, |
|
| 52 | + ], |
|
| 53 | + ], |
|
| 54 | + [ |
|
| 55 | + false, |
|
| 56 | + [ |
|
| 57 | + 'principaluri' => 'user1', |
|
| 58 | + '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 59 | + '{http://owncloud.org/ns}read-only' => false, |
|
| 60 | + ], |
|
| 61 | + ], |
|
| 62 | + // Shared read-only |
|
| 63 | + [ |
|
| 64 | + true, |
|
| 65 | + [ |
|
| 66 | + 'principaluri' => 'user1', |
|
| 67 | + '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 68 | + '{http://owncloud.org/ns}read-only' => 1, |
|
| 69 | + ], |
|
| 70 | + ], |
|
| 71 | + [ |
|
| 72 | + true, |
|
| 73 | + [ |
|
| 74 | + 'principaluri' => 'user1', |
|
| 75 | + '{http://owncloud.org/ns}owner-principal' => 'user2', |
|
| 76 | + '{http://owncloud.org/ns}read-only' => true, |
|
| 77 | + ], |
|
| 78 | + ], |
|
| 79 | + ]; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - #[DataProvider('provideConfidentialObjectData')] |
|
| 83 | - public function testGetWithConfidentialObject( |
|
| 84 | - bool $expectConfidential, |
|
| 85 | - array $calendarInfo, |
|
| 86 | - ): void { |
|
| 87 | - $ics = <<<EOF |
|
| 82 | + #[DataProvider('provideConfidentialObjectData')] |
|
| 83 | + public function testGetWithConfidentialObject( |
|
| 84 | + bool $expectConfidential, |
|
| 85 | + array $calendarInfo, |
|
| 86 | + ): void { |
|
| 87 | + $ics = <<<EOF |
|
| 88 | 88 | BEGIN:VCALENDAR |
| 89 | 89 | CALSCALE:GREGORIAN |
| 90 | 90 | VERSION:2.0 |
@@ -105,34 +105,34 @@ discard block |
||
| 105 | 105 | END:VEVENT |
| 106 | 106 | END:VCALENDAR |
| 107 | 107 | EOF; |
| 108 | - VObjectReader::read($ics); |
|
| 108 | + VObjectReader::read($ics); |
|
| 109 | 109 | |
| 110 | - $calendarObject = new CalendarObject( |
|
| 111 | - $this->calDavBackend, |
|
| 112 | - $this->l10n, |
|
| 113 | - $calendarInfo, |
|
| 114 | - [ |
|
| 115 | - 'uri' => 'a0f55f1f-4f0e-4db8-a54b-1e8b53846591.ics', |
|
| 116 | - 'calendardata' => $ics, |
|
| 117 | - 'classification' => 2, // CalDavBackend::CLASSIFICATION_CONFIDENTIAL |
|
| 118 | - ], |
|
| 119 | - ); |
|
| 110 | + $calendarObject = new CalendarObject( |
|
| 111 | + $this->calDavBackend, |
|
| 112 | + $this->l10n, |
|
| 113 | + $calendarInfo, |
|
| 114 | + [ |
|
| 115 | + 'uri' => 'a0f55f1f-4f0e-4db8-a54b-1e8b53846591.ics', |
|
| 116 | + 'calendardata' => $ics, |
|
| 117 | + 'classification' => 2, // CalDavBackend::CLASSIFICATION_CONFIDENTIAL |
|
| 118 | + ], |
|
| 119 | + ); |
|
| 120 | 120 | |
| 121 | - $actualIcs = $calendarObject->get(); |
|
| 122 | - $vObject = VObjectReader::read($actualIcs); |
|
| 121 | + $actualIcs = $calendarObject->get(); |
|
| 122 | + $vObject = VObjectReader::read($actualIcs); |
|
| 123 | 123 | |
| 124 | - $this->assertInstanceOf(VCalendar::class, $vObject); |
|
| 125 | - $vEvent = $vObject->getBaseComponent('VEVENT'); |
|
| 126 | - $this->assertInstanceOf(VEvent::class, $vEvent); |
|
| 124 | + $this->assertInstanceOf(VCalendar::class, $vObject); |
|
| 125 | + $vEvent = $vObject->getBaseComponent('VEVENT'); |
|
| 126 | + $this->assertInstanceOf(VEvent::class, $vEvent); |
|
| 127 | 127 | |
| 128 | - if ($expectConfidential) { |
|
| 129 | - $this->assertEquals('Busy', $vEvent->SUMMARY?->getValue()); |
|
| 130 | - $this->assertNull($vEvent->DESCRIPTION); |
|
| 131 | - $this->assertNull($vEvent->LOCATION); |
|
| 132 | - } else { |
|
| 133 | - $this->assertEquals('confidential-event', $vEvent->SUMMARY?->getValue()); |
|
| 134 | - $this->assertNotNull($vEvent->DESCRIPTION); |
|
| 135 | - $this->assertNotNull($vEvent->LOCATION); |
|
| 136 | - } |
|
| 137 | - } |
|
| 128 | + if ($expectConfidential) { |
|
| 129 | + $this->assertEquals('Busy', $vEvent->SUMMARY?->getValue()); |
|
| 130 | + $this->assertNull($vEvent->DESCRIPTION); |
|
| 131 | + $this->assertNull($vEvent->LOCATION); |
|
| 132 | + } else { |
|
| 133 | + $this->assertEquals('confidential-event', $vEvent->SUMMARY?->getValue()); |
|
| 134 | + $this->assertNotNull($vEvent->DESCRIPTION); |
|
| 135 | + $this->assertNotNull($vEvent->LOCATION); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | 138 | } |