コード例 #1
0
ファイル: RouteTest.php プロジェクト: Dren-x/mobit
 public function testSetServiceWithPath()
 {
     $route = new Route(array());
     $this->assertNull($route->getPath());
     $this->assertNull($route->getService());
     $route->setPath('/test/');
     $route->setService('app.test');
     $this->assertSame('/test/', $route->getPath());
     $this->assertSame('app.test', $route->getService());
 }
 /**
  * @expectedException \LogicException
  * @expectedExceptionMessage The service option can only be specified at class level.
  */
 public function testServiceOptionIsNotAllowedOnMethod()
 {
     $route = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock();
     $reader = $this->getMockBuilder('Doctrine\\Common\\Annotations\\Reader')->setMethods(array('getClassAnnotation', 'getMethodAnnotations'))->disableOriginalConstructor()->getMockForAbstractClass();
     $annotation = new Route(array());
     $annotation->setService('service');
     $reader->expects($this->once())->method('getClassAnnotation')->will($this->returnValue(null));
     $reader->expects($this->once())->method('getMethodAnnotations')->will($this->returnValue(array($annotation)));
     $loader = $this->getMockBuilder('Sensio\\Bundle\\FrameworkExtraBundle\\Routing\\AnnotatedRouteControllerLoader')->setConstructorArgs(array($reader))->getMock();
     $r = new \ReflectionMethod($loader, 'configureRoute');
     $r->setAccessible(true);
     $r->invoke($loader, $route, new \ReflectionClass($this), new \ReflectionMethod($this, 'testServiceOptionIsNotAllowedOnMethod'), null);
 }