mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 14:50:17 -04:00
Fix CalendarTest
* Made sure delete from self works again (and is tested) Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
c016d947e2
commit
1e6175dfcb
2 changed files with 25 additions and 1 deletions
|
|
@ -153,7 +153,8 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
|||
}
|
||||
|
||||
function delete() {
|
||||
if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
|
||||
if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) &&
|
||||
$this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri']) {
|
||||
$principal = 'principal:' . parent::getOwner();
|
||||
$shares = $this->getShares();
|
||||
$shares = array_filter($shares, function($share) use ($principal){
|
||||
|
|
@ -283,6 +284,10 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable {
|
|||
}
|
||||
|
||||
private function isShared() {
|
||||
if (!isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->calendarInfo['{http://owncloud.org/ns}owner-principal'] !== $this->calendarInfo['principaluri'];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,25 @@ class CalendarTest extends TestCase {
|
|||
$c->delete();
|
||||
}
|
||||
|
||||
public function testDeleteOwn() {
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
|
||||
$backend = $this->createMock(CalDavBackend::class);
|
||||
$backend->expects($this->never())->method('updateShares');
|
||||
$backend->expects($this->never())->method('getShares');
|
||||
|
||||
$backend->expects($this->once())->method('deleteCalendar')
|
||||
->with(666);
|
||||
|
||||
$calendarInfo = [
|
||||
'{http://owncloud.org/ns}owner-principal' => 'user1',
|
||||
'principaluri' => 'user1',
|
||||
'id' => 666,
|
||||
'uri' => 'cal',
|
||||
];
|
||||
$c = new Calendar($backend, $calendarInfo, $this->l10n);
|
||||
$c->delete();
|
||||
}
|
||||
|
||||
public function dataPropPatch() {
|
||||
return [
|
||||
[[], true],
|
||||
|
|
|
|||
Loading…
Reference in a new issue