Skip to content

Commit

Permalink
add initial config test
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiustiniani committed Mar 22, 2014
1 parent d743a8c commit f88d9f8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ php:
env:
- SYMFONY_VERSION=2.2.*
- SYMFONY_VERSION=2.3.*
- SYMFONY_VERSION='2.3.* symfony/expression-language:2.4.* symfony/routing:2.4.*'
- SYMFONY_VERSION=2.4.*
- SYMFONY_VERSION='dev-master symfony/event-dispatcher:~2.5@dev'

Expand Down
5 changes: 5 additions & 0 deletions Tests/Fixtures/Controller/AnnotatedUsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,9 @@ public function splitUserAction($slug)
*/
public function customUserAction($slug)
{}
/**
* @Get(condition="route")
*/
public function conditionalUserAction()
{}
}
6 changes: 6 additions & 0 deletions Tests/Fixtures/Etalon/annotated_users_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ bhead_user:
pattern: /users/{slug}/bhead.{_format}
controller: ::bheadUserAction
requirements: {_method: HEAD}

conditional_user:
pattern: /users/conditional.{_format}
controller: ::conditionalUserAction
requirements: {_method: GET}
condition: route
4 changes: 3 additions & 1 deletion Tests/Routing/Loader/RestRouteLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testAnnotatedUsersFixture()
$etalonRoutes = $this->loadEtalonRoutesInfo('annotated_users_controller.yml');

$this->assertTrue($collection instanceof RestRouteCollection);
$this->assertEquals(17, count($collection->all()));
$this->assertEquals(18, count($collection->all()));

foreach ($etalonRoutes as $name => $params) {
$route = $collection->get($name);
Expand All @@ -103,6 +103,8 @@ public function testAnnotatedUsersFixture()
$this->assertEquals($params['pattern'], $route->getPattern(), 'pattern failed to match for '.$name);
$this->assertEquals($params['requirements'], $route->getRequirements(), 'requirements failed to match for '.$name);
$this->assertContains($params['controller'], $route->getDefault('_controller'), 'controller failed to match for '.$name);
if(isset($params['condition']))
$this->assertEquals($params['condition'], $route->getCondition(), 'condition failed to match for '.$name);
}
}

Expand Down

0 comments on commit f88d9f8

Please sign in to comment.