當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RouteMatchInterface::expects方法代碼示例

本文整理匯總了PHP中Drupal\Core\Routing\RouteMatchInterface::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP RouteMatchInterface::expects方法的具體用法?PHP RouteMatchInterface::expects怎麽用?PHP RouteMatchInterface::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Routing\RouteMatchInterface的用法示例。


在下文中一共展示了RouteMatchInterface::expects方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testHandleIsNotNormalRequestPassThrough

 /**
  * Test passing through isNotNormalRequest when user agent is not a bot.
  *
  * @covers ::handle
  * @covers ::isNotNormalRequest
  * @covers ::__construct
  * @covers ::isIgnoreableRoute
  */
 public function testHandleIsNotNormalRequestPassThrough()
 {
     $config_factory = $this->getConfigFactoryStub();
     $cas_subscriber = $this->getMockBuilder('\\Drupal\\cas\\Subscriber\\CasSubscriber')->setConstructorArgs(array($this->requestStack, $this->routeMatcher, $config_factory, $this->currentUser, $this->conditionManager, $this->casHelper))->setMethods(NULL)->getMock();
     $this->event->expects($this->any())->method('getRequestType')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST));
     $this->routeMatcher->expects($this->once())->method('getRouteName')->will($this->returnValue('not_cas.service'));
     $request_object = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $server = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ServerBag');
     $request_object->server = $server;
     $this->requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request_object));
     $server->expects($this->any())->method('get')->will($this->returnValue('NotAKnownBot'));
     // We want to check that we've gotten past this point.
     $_SESSION['cas_temp_disable'] = TRUE;
     $cas_subscriber->handle($this->event);
 }
開發者ID:anarshi,項目名稱:recap,代碼行數:23,代碼來源:CasSubscriberTest.php

示例2: testGatewayModeIgnoredWhenWebCrawlerRequest

 /**
  * Tests that web crawlers do not trigger gateway mode.
  * 
  * @covers ::handle
  * @covers ::handleGateway
  * @covers ::isCrawlerRequest
  */
 public function testGatewayModeIgnoredWhenWebCrawlerRequest()
 {
     $config_factory = $this->getConfigFactoryStub(array('cas.settings' => array('forced_login.enabled' => FALSE, 'gateway.check_frequency' => CasHelper::CHECK_ALWAYS, 'gateway.paths' => array('<front>'))));
     $cas_subscriber = $this->getMockBuilder('\\Drupal\\cas\\Subscriber\\CasSubscriber')->setConstructorArgs(array($this->requestStack, $this->routeMatcher, $config_factory, $this->currentUser, $this->conditionManager, $this->casHelper))->setMethods(NULL)->getMock();
     $this->event->expects($this->any())->method('getRequestType')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST));
     $this->routeMatcher->expects($this->once())->method('getRouteName')->will($this->returnValue('not_cas.service'));
     $request_object = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
     $server = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ServerBag');
     $request_object->server = $server;
     $request_object->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($request_object));
     $map = array(array('HTTP_USER_AGENT', NULL, FALSE, 'gsa-crawler'));
     $server->expects($this->any())->method('get')->will($this->returnValueMap($map));
     $this->event->expects($this->never())->method('setResponse');
     $cas_subscriber->handle($this->event);
 }
開發者ID:pulibrary,項目名稱:recap,代碼行數:23,代碼來源:CasSubscriberTest.php

示例3: testGetTasksBuildWithCacheabilityMetadata

 /**
  * @covers ::getTasksBuild
  */
 public function testGetTasksBuildWithCacheabilityMetadata()
 {
     $definitions = $this->getLocalTaskFixtures();
     $this->pluginDiscovery->expects($this->once())->method('getDefinitions')->will($this->returnValue($definitions));
     // Set up some cacheablity metadata and ensure its merged together.
     $definitions['menu_local_task_test_tasks_settings']['cache_tags'] = ['tag.example1'];
     $definitions['menu_local_task_test_tasks_settings']['cache_contexts'] = ['context.example1'];
     $definitions['menu_local_task_test_tasks_edit']['cache_tags'] = ['tag.example2'];
     $definitions['menu_local_task_test_tasks_edit']['cache_contexts'] = ['context.example2'];
     // Test the cacheability metadata of access checking.
     $definitions['menu_local_task_test_tasks_view_child1']['access'] = AccessResult::allowed()->addCacheContexts(['user.permissions']);
     $this->setupFactoryAndLocalTaskPlugins($definitions, 'menu_local_task_test_tasks_view');
     $this->setupLocalTaskManager();
     $this->controllerResolver->expects($this->any())->method('getArguments')->willReturn([]);
     $this->routeMatch->expects($this->any())->method('getRouteName')->willReturn('menu_local_task_test_tasks_view');
     $this->routeMatch->expects($this->any())->method('getRawParameters')->willReturn(new ParameterBag());
     $cacheability = new CacheableMetadata();
     $local_tasks = $this->manager->getTasksBuild('menu_local_task_test_tasks_view', $cacheability);
     // Ensure that all cacheability metadata is merged together.
     $this->assertEquals(['tag.example1', 'tag.example2'], $cacheability->getCacheTags());
     $this->assertEquals(['context.example1', 'context.example2', 'route', 'user.permissions'], $cacheability->getCacheContexts());
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:25,代碼來源:LocalTaskManagerTest.php


注:本文中的Drupal\Core\Routing\RouteMatchInterface::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。