本文整理汇总了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);
}
示例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);
}
示例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());
}