コード例 #1
0
 /**
  * @dataProvider datatTestUpdate
  *
  */
 public function testUpdate($owner, $sharedBy)
 {
     $this->provider = $this->getMockBuilder('OCA\\FederatedFileSharing\\FederatedShareProvider')->setConstructorArgs([$this->connection, $this->addressHandler, $this->notifications, $this->tokenHandler, $this->l, $this->logger, $this->rootFolder, $this->config, $this->userManager])->setMethods(['sendPermissionUpdate'])->getMock();
     $share = $this->shareManager->newShare();
     $node = $this->getMock('\\OCP\\Files\\File');
     $node->method('getId')->willReturn(42);
     $node->method('getName')->willReturn('myFile');
     $this->addressHandler->expects($this->any())->method('splitUserRemote')->willReturn(['user', 'server.com']);
     $share->setSharedWith('*****@*****.**')->setSharedBy($sharedBy)->setShareOwner($owner)->setPermissions(19)->setNode($node);
     $this->tokenHandler->method('generateToken')->willReturn('token');
     $this->addressHandler->expects($this->any())->method('generateRemoteURL')->willReturn('http://localhost/');
     $this->notifications->expects($this->once())->method('sendRemoteShare')->with($this->equalTo('token'), $this->equalTo('*****@*****.**'), $this->equalTo('myFile'), $this->anything(), $owner, $owner . '@http://localhost/', $sharedBy, $sharedBy . '@http://localhost/')->willReturn(true);
     if ($owner === $sharedBy) {
         $this->provider->expects($this->never())->method('sendPermissionUpdate');
     } else {
         $this->provider->expects($this->once())->method('sendPermissionUpdate');
     }
     $this->rootFolder->expects($this->never())->method($this->anything());
     $share = $this->provider->create($share);
     $share->setPermissions(1);
     $this->provider->update($share);
     $share = $this->provider->getShareById($share->getId());
     $this->assertEquals(1, $share->getPermissions());
 }