From f88d9f8257172a30f7a28601f6bde4f8ac5ff7f3 Mon Sep 17 00:00:00 2001 From: Mario Giustiniani Date: Sat, 22 Mar 2014 06:55:08 +0100 Subject: [PATCH] add initial config test --- .travis.yml | 1 + Tests/Fixtures/Controller/AnnotatedUsersController.php | 5 +++++ Tests/Fixtures/Etalon/annotated_users_controller.yml | 6 ++++++ Tests/Routing/Loader/RestRouteLoaderTest.php | 4 +++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1a319b562..4deb9f25d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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' diff --git a/Tests/Fixtures/Controller/AnnotatedUsersController.php b/Tests/Fixtures/Controller/AnnotatedUsersController.php index 5a65b75f9..d2470eb64 100644 --- a/Tests/Fixtures/Controller/AnnotatedUsersController.php +++ b/Tests/Fixtures/Controller/AnnotatedUsersController.php @@ -129,4 +129,9 @@ public function splitUserAction($slug) */ public function customUserAction($slug) {} + /** + * @Get(condition="route") + */ + public function conditionalUserAction() + {} } diff --git a/Tests/Fixtures/Etalon/annotated_users_controller.yml b/Tests/Fixtures/Etalon/annotated_users_controller.yml index 60bb35eaa..b2f4aa77d 100644 --- a/Tests/Fixtures/Etalon/annotated_users_controller.yml +++ b/Tests/Fixtures/Etalon/annotated_users_controller.yml @@ -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 diff --git a/Tests/Routing/Loader/RestRouteLoaderTest.php b/Tests/Routing/Loader/RestRouteLoaderTest.php index d62a8c530..dccfbbe70 100644 --- a/Tests/Routing/Loader/RestRouteLoaderTest.php +++ b/Tests/Routing/Loader/RestRouteLoaderTest.php @@ -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); @@ -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); } }