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


PHP Route::expects方法代码示例

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


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

示例1: testChangingDocumentManager

 /**
  * Use getRouteByName() with two different document managers.
  * The two document managers will return different route objects when searching for the same path.
  */
 public function testChangingDocumentManager()
 {
     $this->routeMock->expects($this->any())->method('getPath')->will($this->returnValue('/cms/routes/test-route'));
     $this->route2Mock->expects($this->any())->method('getPath')->will($this->returnValue('/cms/routes/new-route'));
     $this->dmMock->expects($this->any())->method('find')->with(null, '/cms/routes/test-route')->will($this->returnValue($this->routeMock));
     $this->dm2Mock->expects($this->any())->method('find')->with(null, '/cms/routes/test-route')->will($this->returnValue($this->route2Mock));
     $objectManagers = array('default' => $this->dmMock, 'new_manager' => $this->dm2Mock);
     $this->managerRegistryMock = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $this->managerRegistryMock->expects($this->any())->method('getManager')->will($this->returnCallback(function ($name) use($objectManagers) {
         return $objectManagers[$name];
     }));
     $this->candidatesMock->expects($this->any())->method('isCandidate')->will($this->returnValue(true));
     $routeProvider = new RouteProvider($this->managerRegistryMock, $this->candidatesMock);
     $routeProvider->setManagerName('default');
     $foundRoute = $routeProvider->getRouteByName('/cms/routes/test-route');
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $foundRoute);
     $this->assertEquals('/cms/routes/test-route', $foundRoute->getPath());
     $routeProvider->setManagerName('new_manager');
     $newFoundRoute = $routeProvider->getRouteByName('/cms/routes/test-route');
     $this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $newFoundRoute);
     $this->assertEquals('/cms/routes/new-route', $newFoundRoute->getPath());
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:26,代码来源:RouteProviderTest.php

示例2: testApplies

 /**
  * Test the applies() method.
  *
  * @covers ::applies
  *
  * @dataProvider appliesDataProvider
  */
 public function testApplies($path, $return)
 {
     $this->route->expects($this->once())->method('getPath')->willReturn($path);
     $enhancer = new CasRouteEnhancer($this->casHelper);
     $this->assertEquals($return, $enhancer->applies($this->route));
 }
开发者ID:pulibrary,项目名称:recap,代码行数:13,代码来源:CasRouteEnhancerTest.php


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