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


PHP UrlMatcherInterface::expects方法代码示例

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


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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->configFactory = $this->getConfigFactoryStub(['system.site' => ['page.403' => '/access-denied-page', 'page.404' => '/not-found-page']]);
     $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $this->logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->redirectDestination = $this->getMock('\\Drupal\\Core\\Routing\\RedirectDestinationInterface');
     $this->redirectDestination->expects($this->any())->method('getAsArray')->willReturn(['destination' => 'test']);
     $this->accessUnawareRouter = $this->getMock('Symfony\\Component\\Routing\\Matcher\\UrlMatcherInterface');
     $this->accessUnawareRouter->expects($this->any())->method('match')->willReturn(['_controller' => 'mocked']);
     $this->customPageSubscriber = new CustomPageExceptionHtmlSubscriber($this->configFactory, $this->kernel, $this->logger, $this->redirectDestination, $this->accessUnawareRouter);
     // You can't create an exception in PHP without throwing it. Store the
     // current error_log, and disable it temporarily.
     $this->errorLog = ini_set('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul');
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:17,代码来源:CustomPageExceptionHtmlSubscriberTest.php

示例2: testIsValidWithNotExistingPath

 /**
  * Tests the isValid() method with a not existing path.
  *
  * @covers ::isValid
  */
 public function testIsValidWithNotExistingPath()
 {
     $this->account->expects($this->once())->method('hasPermission')->with('link to any page')->willReturn(FALSE);
     $this->accessUnawareRouter->expects($this->never())->method('match');
     $this->accessAwareRouter->expects($this->once())->method('match')->with('/not-existing-path')->willThrowException(new ResourceNotFoundException());
     $this->pathProcessor->expects($this->once())->method('processInbound')->willReturnArgument(0);
     $this->assertFalse($this->pathValidator->isValid('not-existing-path'));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:13,代码来源:PathValidatorTest.php

示例3: testGetUrlIfValidWithoutAccessCheck

 /**
  * Tests the getUrlIfValidWithoutAccessCheck() method.
  *
  * @covers ::getUrlIfValidWithoutAccessCheck
  */
 public function testGetUrlIfValidWithoutAccessCheck()
 {
     $this->account->expects($this->never())->method('hasPermission')->with('link to any page');
     $this->accessAwareRouter->expects($this->never())->method('match');
     $this->accessUnawareRouter->expects($this->once())->method('match')->with('/test-path')->willReturn([RouteObjectInterface::ROUTE_NAME => 'test_route', '_raw_variables' => new ParameterBag(['key' => 'value'])]);
     $this->pathProcessor->expects($this->once())->method('processInbound')->willReturnArgument(0);
     $url = $this->pathValidator->getUrlIfValidWithoutAccessCheck('test-path');
     $this->assertInstanceOf('Drupal\\Core\\Url', $url);
     $this->assertEquals('test_route', $url->getRouteName());
     $this->assertEquals(['key' => 'value'], $url->getRouteParameters());
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:16,代码来源:PathValidatorTest.php

示例4: testProducedLinks

 /**
  * @param string $method
  * @dataProvider getLinkMethods
  */
 public function testProducedLinks($method)
 {
     $listener = $this->getListener();
     $event = $this->getEvent();
     $urlParams = ['foo' => 'bar'];
     $this->urlMatcher->expects($this->exactly(3))->method('match')->willReturn($urlParams);
     $event->getRequest()->setMethod($method);
     $event->getRequest()->headers->set('Link', 'link1,link2, link3');
     $this->context->method('getMethod')->willReturn('METHOD');
     $this->context->expects($this->exactly(2))->method('setMethod')->withConsecutive(['GET'], ['METHOD']);
     $listener->onKernelRequest($event);
     $this->assertTrue($event->getRequest()->attributes->has('links'));
     /** @var LinkHeader[] $links */
     $links = $event->getRequest()->attributes->get('links');
     $this->assertEquals(3, count($links));
     $this->assertEquals('link1', $links[0]->getOriginalHeader());
     $this->assertEquals($urlParams, $links[0]->getUrlParameters());
     $this->assertEquals('link2', $links[1]->getOriginalHeader());
     $this->assertEquals('link3', $links[2]->getOriginalHeader());
 }
开发者ID:ibrows,项目名称:rest-bundle,代码行数:24,代码来源:LinkHeaderListenerTest.php

示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->configFactory = $this->getConfigFactoryStub(['system.site' => ['page.403' => '/access-denied-page', 'page.404' => '/not-found-page']]);
     $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $this->logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->redirectDestination = $this->getMock('\\Drupal\\Core\\Routing\\RedirectDestinationInterface');
     $this->redirectDestination->expects($this->any())->method('getAsArray')->willReturn(['destination' => 'test']);
     $this->accessUnawareRouter = $this->getMock('Symfony\\Component\\Routing\\Matcher\\UrlMatcherInterface');
     $this->accessUnawareRouter->expects($this->any())->method('match')->willReturn(['_controller' => 'mocked']);
     $this->accessManager = $this->getMock('Drupal\\Core\\Access\\AccessManagerInterface');
     $this->accessManager->expects($this->any())->method('checkNamedRoute')->willReturn(AccessResult::allowed()->addCacheTags(['foo', 'bar']));
     $this->customPageSubscriber = new CustomPageExceptionHtmlSubscriber($this->configFactory, $this->kernel, $this->logger, $this->redirectDestination, $this->accessUnawareRouter, $this->accessManager);
     $path_validator = $this->getMock('Drupal\\Core\\Path\\PathValidatorInterface');
     $path_validator->expects($this->any())->method('getUrlIfValidWithoutAccessCheck')->willReturn(Url::fromRoute('foo', ['foo' => 'bar']));
     $container = new ContainerBuilder();
     $container->set('path.validator', $path_validator);
     \Drupal::setContainer($container);
     // You can't create an exception in PHP without throwing it. Store the
     // current error_log, and disable it temporarily.
     $this->errorLog = ini_set('error_log', file_exists('/dev/null') ? '/dev/null' : 'nul');
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:24,代码来源:CustomPageExceptionHtmlSubscriberTest.php

示例6: testHandleWithGetRequest

 /**
  * Tests onHandleException with a GET request.
  */
 public function testHandleWithGetRequest()
 {
     $request = Request::create('/test', 'GET', array('name' => 'druplicon', 'pass' => '12345'));
     $request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, AccessResult::forbidden()->addCacheTags(['druplicon']));
     $request_context = new RequestContext();
     $request_context->fromRequest($request);
     $this->accessUnawareRouter->expects($this->any())->method('getContext')->willReturn($request_context);
     $this->kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
         return new Response($request->getMethod() . ' ' . UrlHelper::buildQuery($request->query->all()));
     }));
     $event = new GetResponseForExceptionEvent($this->kernel, $request, 'foo', new NotFoundHttpException('foo'));
     $this->customPageSubscriber->onException($event);
     $response = $event->getResponse();
     $result = $response->getContent() . " " . UrlHelper::buildQuery($request->request->all());
     $this->assertEquals('GET name=druplicon&pass=12345&destination=test&_exception_statuscode=404 ', $result);
     $this->assertEquals(AccessResult::forbidden()->addCacheTags(['druplicon', 'foo', 'bar']), $request->attributes->get(AccessAwareRouterInterface::ACCESS_RESULT));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:20,代码来源:CustomPageExceptionHtmlSubscriberTest.php


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