本文整理匯總了PHP中OCP\Files\Folder::method方法的典型用法代碼示例。如果您正苦於以下問題:PHP Folder::method方法的具體用法?PHP Folder::method怎麽用?PHP Folder::method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OCP\Files\Folder
的用法示例。
在下文中一共展示了Folder::method方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetAvatar
public function testSetAvatar()
{
$oldFile = $this->getMock('\\OCP\\Files\\File');
$this->folder->method('get')->will($this->returnValueMap([['avatar.jpg', $oldFile], ['avatar.png', $oldFile]]));
$oldFile->expects($this->exactly(2))->method('delete');
$newFile = $this->getMock('\\OCP\\Files\\File');
$this->folder->expects($this->once())->method('newFile')->with('avatar.png')->willReturn($newFile);
$image = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$newFile->expects($this->once())->method('putContent')->with($image->data());
$this->avatar->set($image->data());
}
示例2: testGetChildren
public function testGetChildren()
{
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), 'file_source' => $qb->expr()->literal(42), 'file_target' => $qb->expr()->literal('myTarget'), 'permissions' => $qb->expr()->literal(13)]);
$qb->execute();
// Get the id
$qb = $this->dbConn->getQueryBuilder();
$cursor = $qb->select('id')->from('share')->setMaxResults(1)->orderBy('id', 'DESC')->execute();
$id = $cursor->fetch();
$id = $id['id'];
$cursor->closeCursor();
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), 'share_with' => $qb->expr()->literal('user1'), 'uid_owner' => $qb->expr()->literal('user2'), 'item_type' => $qb->expr()->literal('file'), 'file_source' => $qb->expr()->literal(1), 'file_target' => $qb->expr()->literal('myTarget1'), 'permissions' => $qb->expr()->literal(2), 'parent' => $qb->expr()->literal($id)]);
$qb->execute();
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), 'share_with' => $qb->expr()->literal('group1'), 'uid_owner' => $qb->expr()->literal('user3'), 'item_type' => $qb->expr()->literal('folder'), 'file_source' => $qb->expr()->literal(3), 'file_target' => $qb->expr()->literal('myTarget2'), 'permissions' => $qb->expr()->literal(4), 'parent' => $qb->expr()->literal($id)]);
$qb->execute();
$storage = $this->getMock('OC\\Files\\Storage\\Storage');
$storage->method('getOwner')->willReturn('shareOwner');
$path1 = $this->getMock('OCP\\Files\\File');
$path1->expects($this->once())->method('getStorage')->willReturn($storage);
$path2 = $this->getMock('OCP\\Files\\Folder');
$path2->expects($this->once())->method('getStorage')->willReturn($storage);
$this->userFolder->method('getById')->will($this->returnValueMap([[1, [$path1]], [3, [$path2]]]));
$shareOwner = $this->getMock('OCP\\IUser');
$user1 = $this->getMock('OCP\\IUser');
$user2 = $this->getMock('OCP\\IUser');
$user3 = $this->getMock('OCP\\IUser');
$this->userManager->method('get')->will($this->returnValueMap([['shareOwner', $shareOwner], ['user1', $user1], ['user2', $user2], ['user3', $user3]]));
$group1 = $this->getMock('OCP\\IGroup');
$this->groupManager->method('get')->will($this->returnValueMap([['group1', $group1]]));
$share = $this->getMock('\\OC\\Share20\\IShare');
$share->method('getId')->willReturn($id);
$children = $this->provider->getChildren($share);
$this->assertCount(2, $children);
//Child1
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $children[0]->getShareType());
$this->assertEquals($user1, $children[0]->getSharedWith());
$this->assertEquals($user2, $children[0]->getSharedBy());
$this->assertEquals($shareOwner, $children[0]->getShareOwner());
$this->assertEquals($path1, $children[0]->getPath());
$this->assertEquals(2, $children[0]->getPermissions());
$this->assertEquals(null, $children[0]->getToken());
$this->assertEquals(null, $children[0]->getExpirationDate());
$this->assertEquals('myTarget1', $children[0]->getTarget());
//Child2
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $children[1]->getShareType());
$this->assertEquals($group1, $children[1]->getSharedWith());
$this->assertEquals($user3, $children[1]->getSharedBy());
$this->assertEquals($shareOwner, $children[1]->getShareOwner());
$this->assertEquals($path2, $children[1]->getPath());
$this->assertEquals(4, $children[1]->getPermissions());
$this->assertEquals(null, $children[1]->getToken());
$this->assertEquals(null, $children[1]->getExpirationDate());
$this->assertEquals('myTarget2', $children[1]->getTarget());
}
示例3: testDeleteNestedShares
public function testDeleteNestedShares()
{
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), 'file_source' => $qb->expr()->literal(42), 'file_target' => $qb->expr()->literal('myTarget'), 'permissions' => $qb->expr()->literal(13)]);
$this->assertEquals(1, $qb->execute());
// Get the id
$qb = $this->dbConn->getQueryBuilder();
$cursor = $qb->select('id')->from('share')->setMaxResults(1)->orderBy('id', 'DESC')->execute();
$id1 = $cursor->fetch();
$id1 = $id1['id'];
$cursor->closeCursor();
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), 'file_source' => $qb->expr()->literal(42), 'file_target' => $qb->expr()->literal('myTarget'), 'permissions' => $qb->expr()->literal(13), 'parent' => $qb->expr()->literal($id1)]);
$this->assertEquals(1, $qb->execute());
// Get the id
$qb = $this->dbConn->getQueryBuilder();
$cursor = $qb->select('id')->from('share')->setMaxResults(1)->orderBy('id', 'DESC')->execute();
$id2 = $cursor->fetch();
$id2 = $id2['id'];
$cursor->closeCursor();
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), 'file_source' => $qb->expr()->literal(42), 'file_target' => $qb->expr()->literal('myTarget'), 'permissions' => $qb->expr()->literal(13), 'parent' => $qb->expr()->literal($id2)]);
$this->assertEquals(1, $qb->execute());
$storage = $this->getMock('OC\\Files\\Storage\\Storage');
$storage->method('getOwner')->willReturn('shareOwner');
$path = $this->getMock('OCP\\Files\\Node');
$path->method('getStorage')->wilLReturn($storage);
$this->userFolder->method('getById')->with(42)->willReturn([$path]);
$sharedWith = $this->getMock('OCP\\IUser');
$sharedWith->method('getUID')->willReturn('sharedWith');
$sharedBy = $this->getMock('OCP\\IUser');
$sharedBy->method('getUID')->willReturn('sharedBy');
$shareOwner = $this->getMock('OCP\\IUser');
$this->userManager->method('get')->will($this->returnValueMap([['sharedWith', $sharedWith], ['sharedBy', $sharedBy], ['shareOwner', $shareOwner]]));
$share = $this->provider->getShareById($id1);
$this->provider->delete($share);
$qb = $this->dbConn->getQueryBuilder();
$qb->select('*')->from('share');
$cursor = $qb->execute();
$result = $cursor->fetchAll();
$cursor->closeCursor();
$this->assertEmpty($result);
}
示例4: testSetAvatar
public function testSetAvatar()
{
$avatarFileJPG = $this->getMock('\\OCP\\Files\\File');
$avatarFileJPG->method('getName')->willReturn('avatar.jpg');
$avatarFileJPG->expects($this->once())->method('delete');
$avatarFilePNG = $this->getMock('\\OCP\\Files\\File');
$avatarFilePNG->method('getName')->willReturn('avatar.png');
$avatarFilePNG->expects($this->once())->method('delete');
$resizedAvatarFile = $this->getMock('\\OCP\\Files\\File');
$resizedAvatarFile->method('getName')->willReturn('avatar.32.jpg');
$resizedAvatarFile->expects($this->once())->method('delete');
$nonAvatarFile = $this->getMock('\\OCP\\Files\\File');
$nonAvatarFile->method('getName')->willReturn('avatarX');
$nonAvatarFile->expects($this->never())->method('delete');
$this->folder->method('search')->with('avatar')->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile, $nonAvatarFile]);
$newFile = $this->getMock('\\OCP\\Files\\File');
$this->folder->expects($this->once())->method('newFile')->with('avatar.png')->willReturn($newFile);
$image = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$newFile->expects($this->once())->method('putContent')->with($image->data());
$this->avatar->set($image->data());
}