本文整理汇总了PHP中OC\Files\View::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP View::expects方法的具体用法?PHP View::expects怎么用?PHP View::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\View
的用法示例。
在下文中一共展示了View::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMoveSrcDeletable
public function testMoveSrcDeletable()
{
$fileInfoFolderATestTXT = $this->getMockBuilder('\\OCP\\Files\\FileInfo')->disableOriginalConstructor()->getMock();
$fileInfoFolderATestTXT->expects($this->once())->method('isDeletable')->willReturn(true);
$this->view->expects($this->once())->method('getFileInfo')->with('FolderA/test.txt')->willReturn($fileInfoFolderATestTXT);
$this->plugin->checkMove('FolderA/test.txt', 'test.txt');
}
示例2: testGetPreview
/**
* @dataProvider dataGetPreview
*
* @param string $author
* @param int $fileId
* @param string $path
* @param string $returnedPath
* @param bool $isDir
* @param bool $isMimeSup
* @param string $source
* @param bool $isMimeTypeIcon
*/
public function testGetPreview($author, $fileId, $path, $returnedPath, $isDir, $isMimeSup, $source, $isMimeTypeIcon)
{
$controller = $this->getController(['getPreviewLink', 'getPreviewPathFromMimeType']);
$this->infoCache->expects($this->once())->method('getInfoById')->with($author, $fileId, $path)->willReturn(['path' => $returnedPath, 'exists' => true, 'is_dir' => $isDir, 'view' => '']);
$controller->expects($this->once())->method('getPreviewLink')->with($returnedPath, $isDir)->willReturnCallback(function ($path) {
return '/preview' . $path;
});
if ($isDir) {
$controller->expects($this->once())->method('getPreviewPathFromMimeType')->with('dir')->willReturn('/preview/dir');
} else {
$fileInfo = $this->getMockBuilder('OCP\\Files\\FileInfo')->disableOriginalConstructor()->getMock();
$this->view->expects($this->once())->method('chroot')->with('/' . $author . '/files');
$this->view->expects($this->once())->method('getFileInfo')->with($returnedPath)->willReturn($fileInfo);
$this->preview->expects($this->once())->method('isAvailable')->with($fileInfo)->willReturn($isMimeSup);
if (!$isMimeSup) {
$fileInfo->expects($this->once())->method('getMimetype')->willReturn('audio/mp3');
$controller->expects($this->once())->method('getPreviewPathFromMimeType')->with('audio/mp3')->willReturn('/preview/mpeg');
} else {
$this->urlGenerator->expects($this->once())->method('linkToRoute')->with('core_ajax_preview', $this->anything())->willReturnCallback(function () use($returnedPath) {
return '/preview' . $returnedPath;
});
}
}
$this->assertSame(['link' => '/preview' . $returnedPath, 'source' => $source, 'isMimeTypeIcon' => $isMimeTypeIcon], $this->invokePrivate($controller, 'getPreview', [$author, $fileId, $path]));
}
示例3: testRecoverUserFiles
public function testRecoverUserFiles()
{
$this->viewMock->expects($this->once())->method('getDirectoryContent')->willReturn([]);
$this->cryptMock->expects($this->once())->method('decryptPrivateKey');
$this->instance->recoverUsersFiles('password', 'admin');
$this->assertTrue(true);
}
示例4: testShareNotificationForSharer
/**
* @dataProvider dataShareNotificationForSharer
* @param string $path
*/
public function testShareNotificationForSharer($path)
{
$filesHooks = $this->getFilesHooks(['addNotificationsForUser']);
$this->view->expects($this->once())->method('getPath')->willReturn($path);
$this->settings->expects($path !== null ? $this->exactly(3) : $this->never())->method('getUserSetting')->willReturnMap([['user', 'stream', Files_Sharing::TYPE_SHARED, true], ['user', 'email', Files_Sharing::TYPE_SHARED, true], ['user', 'setting', 'batchtime', 21]]);
$filesHooks->expects($path !== null ? $this->once() : $this->never())->method('addNotificationsForUser')->with('user', 'subject', ['/path', 'target'], 42, '/path', true, true, 21);
$this->invokePrivate($filesHooks, 'shareNotificationForSharer', ['subject', 'target', 42, 'file']);
}
示例5: testGetStorage
public function testGetStorage()
{
$return = $this->getMockBuilder('OC\\Files\\Storage\\Storage')->disableOriginalConstructor()->getMock();
$path = '/foo/bar.txt';
$this->filesMock->expects($this->once())->method('getMount')->with($path)->willReturn($this->mountMock);
$this->mountMock->expects($this->once())->method('getStorage')->willReturn($return);
$this->assertEquals($return, $this->instance->getStorage($path));
}
示例6: testFindInfoById
/**
* @dataProvider dataFindInfoById
*
* @param string $user
* @param int $fileId
* @param string $filename
* @param string|null $path
* @param string|null $pathTrash
* @param string $isDirPath
* @param bool $isDir
* @param string $expected
* @param array $expectedCache
*/
public function testFindInfoById($user, $fileId, $filename, $path, $pathTrash, $isDirPath, $isDir, $expected, array $expectedCache)
{
$this->view->expects($this->at(0))->method('chroot')->with('/' . $user . '/files');
if ($path === null) {
$this->view->expects($this->at(1))->method('getPath')->with($fileId)->willThrowException(new NotFoundException());
$this->view->expects($this->at(2))->method('chroot')->with('/' . $user . '/files_trashbin');
if ($pathTrash === null) {
$this->view->expects($this->at(3))->method('getPath')->with($fileId)->willThrowException(new NotFoundException());
} else {
$this->view->expects($this->at(3))->method('getPath')->with($fileId)->willReturn($pathTrash);
}
} else {
$this->view->expects($this->at(1))->method('getPath')->with($fileId)->willReturn($path);
}
$this->view->expects($path === null && $pathTrash === null ? $this->never() : $this->once())->method('is_dir')->with($isDirPath)->willReturn($isDir);
$infoCache = $this->getCache();
$this->assertSame($expected, $this->invokePrivate($infoCache, 'findInfoById', [$user, $fileId, $filename]));
$this->assertSame($expectedCache, $this->invokePrivate($infoCache, 'cacheId'));
}
示例7: testMoveSrcNotExist
/**
* @expectedException \Sabre\DAV\Exception\NotFound
* @expectedExceptionMessage FolderA/test.txt does not exist
*/
public function testMoveSrcNotExist()
{
$this->view->expects($this->once())->method('getFileInfo')->with('FolderA/test.txt')->willReturn(false);
$this->plugin->checkMove('FolderA/test.txt', 'test.txt');
}