예제 #1
0
 /**
  * @dataProvider providesReadOnlyInfo
  */
 public function testAcl($expectsWrite, $readOnlyValue, $hasOwnerSet, $uri = 'default')
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */
     $backend = $this->getMockBuilder('OCA\\DAV\\CalDAV\\CalDavBackend')->disableOriginalConstructor()->getMock();
     $backend->expects($this->any())->method('applyShareAcl')->willReturnArgument(1);
     $calendarInfo = ['principaluri' => 'user2', 'id' => 666, 'uri' => $uri];
     if (!is_null($readOnlyValue)) {
         $calendarInfo['{http://owncloud.org/ns}read-only'] = $readOnlyValue;
     }
     if ($hasOwnerSet) {
         $calendarInfo['{http://owncloud.org/ns}owner-principal'] = 'user1';
     }
     $c = new Calendar($backend, $calendarInfo, $this->l10n);
     $acl = $c->getACL();
     $childAcl = $c->getChildACL();
     $expectedAcl = [['privilege' => '{DAV:}read', 'principal' => $hasOwnerSet ? 'user1' : 'user2', 'protected' => true], ['privilege' => '{DAV:}write', 'principal' => $hasOwnerSet ? 'user1' : 'user2', 'protected' => true]];
     if ($uri === BirthdayService::BIRTHDAY_CALENDAR_URI) {
         $expectedAcl = [['privilege' => '{DAV:}read', 'principal' => $hasOwnerSet ? 'user1' : 'user2', 'protected' => true]];
     }
     if ($hasOwnerSet) {
         $expectedAcl[] = ['privilege' => '{DAV:}read', 'principal' => 'user2', 'protected' => true];
         if ($expectsWrite) {
             $expectedAcl[] = ['privilege' => '{DAV:}write', 'principal' => 'user2', 'protected' => true];
         }
     }
     $this->assertEquals($expectedAcl, $acl);
     $this->assertEquals($expectedAcl, $childAcl);
 }