当前位置: 首页>>代码示例>>PHP>>正文


PHP IURLGenerator::expects方法代码示例

本文整理汇总了PHP中OCP\IURLGenerator::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP IURLGenerator::expects方法的具体用法?PHP IURLGenerator::expects怎么用?PHP IURLGenerator::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\IURLGenerator的用法示例。


在下文中一共展示了IURLGenerator::expects方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFormat

 /**
  * @dataProvider dataFormat
  *
  * @param string $user
  * @param string $parameter
  * @param bool $isDir
  * @param array $info
  * @param bool $allowHtml
  * @param bool $verbose
  * @param string $expected
  */
 public function testFormat($user, $parameter, $isDir, array $info, $allowHtml, $verbose, $expected)
 {
     /** @var \OCP\Activity\IEvent|\PHPUnit_Framework_MockObject_MockObject $event */
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     if (!empty($info)) {
         $event->expects($this->once())->method('getObjectType')->willReturn('files');
         $event->expects($this->once())->method('getObjectName')->willReturn($parameter);
         $event->expects($this->once())->method('getObjectId')->willReturn(42);
     }
     $this->urlGenerator->expects($allowHtml ? $this->once() : $this->never())->method('linkTo')->with('files', 'index.php', $this->anything())->willReturnCallback(function ($app, $file, $parameters) {
         $paramList = [];
         foreach ($parameters as $key => $value) {
             $paramList[] = $key . '=' . urlencode($value);
         }
         return $app . '/' . $file . '?' . implode('&', $paramList);
     });
     $formatter = $this->getFormatter(['fixLegacyFilename'], $user);
     $formatter->expects($this->once())->method('fixLegacyFilename')->willReturnArgument(0);
     if (!empty($info)) {
         $this->infoCache->expects($this->once())->method('getInfoById')->with($user, 42, $parameter)->willReturn($info);
     } else {
         $this->infoCache->expects($this->once())->method('getInfoByPath')->with($user, $parameter)->willReturn(['path' => $parameter, 'is_dir' => $isDir, 'exists' => true, 'view' => '']);
     }
     $this->assertSame($expected, $formatter->format($event, $parameter, $allowHtml, $verbose));
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:36,代码来源:fileformattertest.php

示例2: testIndexWithIE8RedirectAndViewAndDirDefined

 public function testIndexWithIE8RedirectAndViewAndDirDefined()
 {
     $this->request->expects($this->once())->method('isUserAgent')->with(['/MSIE 8.0/'])->will($this->returnValue(true));
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('files.view.index')->will($this->returnValue('/apps/files/'));
     $expected = new RedirectResponse('/apps/files/#?dir=MyDir&view=MyView');
     $this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
 }
开发者ID:kenwi,项目名称:core,代码行数:7,代码来源:ViewControllerTest.php

示例3: testLogoutWithToken

 public function testLogoutWithToken()
 {
     $this->request->expects($this->once())->method('getCookie')->with('oc_token')->willReturn('MyLoginToken');
     $user = $this->getMock('\\OCP\\IUser');
     $user->expects($this->once())->method('getUID')->willReturn('JohnDoe');
     $this->userSession->expects($this->once())->method('getUser')->willReturn($user);
     $this->config->expects($this->once())->method('deleteUserValue')->with('JohnDoe', 'login_token', 'MyLoginToken');
     $this->urlGenerator->expects($this->once())->method('linkToRouteAbsolute')->with('core.login.showLoginForm')->willReturn('/login');
     $expected = new RedirectResponse('/login');
     $this->assertEquals($expected, $this->loginController->logout());
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:11,代码来源:LoginControllerTest.php

示例4: testAppNavigation

 public function testAppNavigation()
 {
     $this->navigationManager->expects($this->once())->method('add')->willReturnCallback(function ($closure) {
         $this->assertInstanceOf('\\Closure', $closure);
         $navigation = $closure();
         $this->assertInternalType('array', $navigation);
         $this->assertCount(5, $navigation);
         $this->assertSame(['id' => 'announcementcenter', 'order' => 10, 'href' => '/apps/announcementcenter/announcement', 'icon' => '/apps/announcementcenter/img/announcementcenter.svg', 'name' => 'Announcements'], $navigation);
     });
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('announcementcenter.page.index')->willReturn('/apps/announcementcenter/announcement');
     $this->urlGenerator->expects($this->once())->method('imagePath')->with('announcementcenter', 'announcementcenter.svg')->willReturn('/apps/announcementcenter/img/announcementcenter.svg');
     $this->languageFactory->expects($this->once())->method('get')->with('announcementcenter')->willReturn($this->language);
     include __DIR__ . '/../../appinfo/app.php';
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:14,代码来源:AppTest.php

示例5: testRescanFailedIntegrityCheck

 public function testRescanFailedIntegrityCheck()
 {
     $this->checker->expects($this->once())->method('runInstanceVerification');
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('settings_admin')->will($this->returnValue('/admin'));
     $expected = new RedirectResponse('/admin');
     $this->assertEquals($expected, $this->checkSetupController->rescanFailedIntegrityCheck());
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:7,代码来源:CheckSetupControllerTest.php

示例6: testCheckAppUpdates

 /**
  * @dataProvider dataCheckAppUpdates
  *
  * @param string[] $apps
  * @param array $isUpdateAvailable
  * @param array $notifications
  */
 public function testCheckAppUpdates(array $apps, array $isUpdateAvailable, array $notifications)
 {
     $job = $this->getJob(['isUpdateAvailable', 'createNotifications']);
     $this->appManager->expects($this->once())->method('getInstalledApps')->willReturn($apps);
     $job->expects($this->exactly(sizeof($apps)))->method('isUpdateAvailable')->willReturnMap($isUpdateAvailable);
     $this->urlGenerator->expects($this->exactly(sizeof($notifications)))->method('linkToRouteAbsolute')->with('settings.AppSettings.viewApps')->willReturn('apps-url');
     $mockedMethod = $job->expects($this->exactly(sizeof($notifications)))->method('createNotifications');
     call_user_func_array([$mockedMethod, 'withConsecutive'], $notifications);
     $this->invokePrivate($job, 'checkAppUpdates');
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:17,代码来源:BackgroundJobTest.php

示例7: testCheck

 public function testCheck()
 {
     $this->config->expects($this->at(0))->method('getSystemValue')->with('has_internet_connection', true)->will($this->returnValue(true));
     $this->config->expects($this->at(1))->method('getSystemValue')->with('memcache.local', null)->will($this->returnValue('SomeProvider'));
     $client = $this->getMockBuilder('\\OCP\\Http\\Client\\IClient')->disableOriginalConstructor()->getMock();
     $client->expects($this->at(0))->method('get')->with('https://www.owncloud.org/', []);
     $client->expects($this->at(1))->method('get')->with('http://www.owncloud.org/', [])->will($this->throwException(new \Exception()));
     $this->clientService->expects($this->once())->method('newClient')->will($this->returnValue($client));
     $this->util->expects($this->once())->method('isHtaccessWorking')->will($this->returnValue(true));
     $this->urlGenerator->expects($this->once())->method('linkToDocs')->with('admin-performance')->willReturn('http://doc.owncloud.org/server/go.php?to=admin-performance');
     $expected = new DataResponse(['serverHasInternetConnection' => false, 'dataDirectoryProtected' => true, 'isMemcacheConfigured' => true, 'memcacheDocs' => 'http://doc.owncloud.org/server/go.php?to=admin-performance']);
     $this->assertEquals($expected, $this->checkSetupController->check());
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:13,代码来源:CheckSetupControllerTest.php

示例8: testCheck

 public function testCheck()
 {
     $this->config->expects($this->at(0))->method('getSystemValue')->with('has_internet_connection', true)->will($this->returnValue(true));
     $this->config->expects($this->at(1))->method('getSystemValue')->with('memcache.local', null)->will($this->returnValue('SomeProvider'));
     $this->config->expects($this->at(2))->method('getSystemValue')->with('trusted_proxies', [])->willReturn(['1.2.3.4']);
     $this->request->expects($this->once())->method('getRemoteAddress')->willReturn('4.3.2.1');
     $client = $this->getMockBuilder('\\OCP\\Http\\Client\\IClient')->disableOriginalConstructor()->getMock();
     $client->expects($this->at(0))->method('get')->with('https://www.owncloud.org/', []);
     $client->expects($this->at(1))->method('get')->with('http://www.owncloud.org/', [])->will($this->throwException(new \Exception()));
     $this->clientService->expects($this->once())->method('newClient')->will($this->returnValue($client));
     $this->util->expects($this->once())->method('isHtaccessWorking')->will($this->returnValue(true));
     $this->urlGenerator->expects($this->at(0))->method('linkToDocs')->with('admin-performance')->willReturn('http://doc.owncloud.org/server/go.php?to=admin-performance');
     $this->urlGenerator->expects($this->at(1))->method('linkToDocs')->with('admin-security')->willReturn('https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html');
     self::$version_compare = -1;
     $this->urlGenerator->expects($this->at(2))->method('linkToDocs')->with('admin-reverse-proxy')->willReturn('reverse-proxy-doc-link');
     $expected = new DataResponse(['serverHasInternetConnection' => false, 'dataDirectoryProtected' => true, 'isMemcacheConfigured' => true, 'memcacheDocs' => 'http://doc.owncloud.org/server/go.php?to=admin-performance', 'isUrandomAvailable' => self::invokePrivate($this->checkSetupController, 'isUrandomAvailable'), 'securityDocs' => 'https://doc.owncloud.org/server/8.1/admin_manual/configuration_server/hardening.html', 'isUsedTlsLibOutdated' => '', 'phpSupported' => ['eol' => true, 'version' => PHP_VERSION], 'forwardedForHeadersWorking' => true, 'reverseProxyDocs' => 'reverse-proxy-doc-link']);
     $this->assertEquals($expected, $this->checkSetupController->check());
 }
开发者ID:GrumpyCrouton,项目名称:core,代码行数:18,代码来源:CheckSetupControllerTest.php

示例9: testShowFileRouteWithTrashedFile

 /**
  * @dataProvider showFileMethodProvider
  */
 public function testShowFileRouteWithTrashedFile($useShowFile)
 {
     $this->appManager->expects($this->once())->method('isEnabledForUser')->with('files_trashbin')->will($this->returnValue(true));
     $parentNode = $this->getMock('\\OCP\\Files\\Folder');
     $parentNode->expects($this->once())->method('getPath')->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub'));
     $baseFolderFiles = $this->getMock('\\OCP\\Files\\Folder');
     $baseFolderTrash = $this->getMock('\\OCP\\Files\\Folder');
     $this->rootFolder->expects($this->at(0))->method('get')->with('testuser1/files/')->will($this->returnValue($baseFolderFiles));
     $this->rootFolder->expects($this->at(1))->method('get')->with('testuser1/files_trashbin/files/')->will($this->returnValue($baseFolderTrash));
     $baseFolderFiles->expects($this->once())->method('getById')->with(123)->will($this->returnValue([]));
     $node = $this->getMock('\\OCP\\Files\\File');
     $node->expects($this->once())->method('getParent')->will($this->returnValue($parentNode));
     $node->expects($this->once())->method('getName')->will($this->returnValue('somefile.txt'));
     $baseFolderTrash->expects($this->at(0))->method('getById')->with(123)->will($this->returnValue([$node]));
     $baseFolderTrash->expects($this->at(1))->method('getRelativePath')->with('testuser1/files_trashbin/files/test.d1462861890/sub')->will($this->returnValue('/test.d1462861890/sub'));
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('files.view.index', ['view' => 'trashbin', 'dir' => '/test.d1462861890/sub', 'scrollto' => 'somefile.txt'])->will($this->returnValue('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt'));
     $expected = new Http\RedirectResponse('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt');
     if ($useShowFile) {
         $this->assertEquals($expected, $this->viewController->showFile(123));
     } else {
         $this->assertEquals($expected, $this->viewController->index('/whatever', '', '123'));
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:26,代码来源:ViewControllerTest.php

示例10: testGetPreviewLink

 /**
  * @dataProvider dataGetPreviewLink
  *
  * @param string $path
  * @param bool $isDir
  * @param array $expected
  */
 public function testGetPreviewLink($path, $isDir, $expected)
 {
     $this->urlGenerator->expects($this->once())->method('linkTo')->with('files', 'index.php', $expected);
     $this->invokePrivate($this->controller, 'getPreviewLink', [$path, $isDir]);
 }
开发者ID:ynott,项目名称:activity,代码行数:12,代码来源:ocsendpointtest.php

示例11: mockUrlToErrorPage

 /**
  * Mocks IURLGenerator->linkToRoute()
  *
  * @param int $code
  * @param string $url
  */
 private function mockUrlToErrorPage($code, $url)
 {
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with($this->appName . '.page.error_page', ['code' => $code])->willReturn($url);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:10,代码来源:EnvCheckMiddlewareTest.php

示例12: mockUrlToDownloadPage

 private function mockUrlToDownloadPage($token, $fileId, $filename, $url)
 {
     $this->urlGenerator->expects($this->once())->method('linkToRoute')->with($this->appName . '.files_public.download', ['token' => $token, 'fileId' => $fileId, 'filename' => $filename])->willReturn($url);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:4,代码来源:PageControllerTest.php


注:本文中的OCP\IURLGenerator::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。