Skip to content

Commit

Permalink
minor #9880 test for class route annotation (ewgRa)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.5-dev branch.

Discussion
----------

test for class route annotation

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

I mention that AnnotationClassLoaderTest don't test class route annotation functional.

This patch add test for class route annotation

Commits
-------

ac94ddb test for class route annotation
  • Loading branch information
fabpot committed Jan 3, 2014
2 parents 60c2140 + ac94ddb commit f499094
Showing 1 changed file with 26 additions and 0 deletions.
Expand Up @@ -125,6 +125,32 @@ public function testLoad($className, $routeDatas = array(), $methodArgs = array(
$this->assertEquals($routeDatas['condition'], $route->getCondition(), '->load preserves condition annotation');
}

public function testClassRouteLoad()
{
$classRouteDatas = array('path' => '/classRoutePrefix');

$routeDatas = array(
'name' => 'route1',
'path' => '/',
);

$this->reader
->expects($this->once())
->method('getClassAnnotation')
->will($this->returnValue($this->getAnnotatedRoute($classRouteDatas)))
;

$this->reader
->expects($this->once())
->method('getMethodAnnotations')
->will($this->returnValue(array($this->getAnnotatedRoute($routeDatas))))
;
$routeCollection = $this->loader->load('Symfony\Component\Routing\Tests\Fixtures\AnnotatedClasses\BarClass');
$route = $routeCollection->get($routeDatas['name']);

$this->assertSame($classRouteDatas['path'].$routeDatas['path'], $route->getPath(), '->load preserves class route path annotation');
}

private function getAnnotatedRoute($datas)
{
return new Route($datas);
Expand Down

0 comments on commit f499094

Please sign in to comment.