calDavBackend = $this->createMock(CalDavBackend::class); $this->l10n = $this->createMock(IL10N::class); $this->l10n->method('t') ->willReturnArgument(0); } public static function provideConfidentialObjectData(): array { return [ // Shared writable [ false, [ 'principaluri' => 'user1', '{http://owncloud.org/ns}owner-principal' => 'user2', ], ], [ false, [ 'principaluri' => 'user1', '{http://owncloud.org/ns}owner-principal' => 'user2', '{http://owncloud.org/ns}read-only' => 0, ], ], [ false, [ 'principaluri' => 'user1', '{http://owncloud.org/ns}owner-principal' => 'user2', '{http://owncloud.org/ns}read-only' => false, ], ], // Shared read-only [ true, [ 'principaluri' => 'user1', '{http://owncloud.org/ns}owner-principal' => 'user2', '{http://owncloud.org/ns}read-only' => 1, ], ], [ true, [ 'principaluri' => 'user1', '{http://owncloud.org/ns}owner-principal' => 'user2', '{http://owncloud.org/ns}read-only' => true, ], ], ]; } #[DataProvider('provideConfidentialObjectData')] public function testGetWithConfidentialObject( bool $expectConfidential, array $calendarInfo, ): void { $ics = <<calDavBackend, $this->l10n, $calendarInfo, [ 'uri' => 'a0f55f1f-4f0e-4db8-a54b-1e8b53846591.ics', 'calendardata' => $ics, 'classification' => 2, // CalDavBackend::CLASSIFICATION_CONFIDENTIAL ], ); $actualIcs = $calendarObject->get(); $vObject = VObjectReader::read($actualIcs); $this->assertInstanceOf(VCalendar::class, $vObject); $vEvent = $vObject->getBaseComponent('VEVENT'); $this->assertInstanceOf(VEvent::class, $vEvent); if ($expectConfidential) { $this->assertEquals('Busy', $vEvent->SUMMARY?->getValue()); $this->assertNull($vEvent->DESCRIPTION); $this->assertNull($vEvent->LOCATION); } else { $this->assertEquals('confidential-event', $vEvent->SUMMARY?->getValue()); $this->assertNotNull($vEvent->DESCRIPTION); $this->assertNotNull($vEvent->LOCATION); } } }