Skip to content

Commit 33a200d

Browse files
committed
#718 - Test for options being parsed in annotations
1 parent 8b868df commit 33a200d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Tests/Fixtures/Controller/AnnotatedUsersController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public function getUsersAction()
4646
public function getUserAction($slug)
4747
{} // [GET] /users/{slug}
4848

49+
/**
50+
* @Route(requirements={"slug" = "[a-z]+", "id" = "\d+"}, options={"expose"=true})
51+
*/
52+
public function getUserPostAction($slug, $id)
53+
{} // [GET] /users/{slug}/posts/{id}
54+
4955
/**
5056
* @Patch
5157
*/

Tests/Fixtures/Etalon/annotated_users_controller.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ get_user_comment:
2323
controller: ::getUserCommentAction
2424
requirements: {_method: GET, slug: '[a-z]+', id: '\d+'}
2525

26+
get_user_post:
27+
pattern: /users/{slug}/posts/{id}.{_format}
28+
controller: ::getUserPostAction
29+
options:
30+
expose: true
31+
requirements: {_method: GET, slug: '[a-z]+', id: '\d+'}
32+
2633
rate_user:
2734
pattern: /users/{slug}/rate.{_format}
2835
controller: ::rateUserAction

Tests/Routing/Loader/RestRouteLoaderTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testAnnotatedUsersFixture()
9494
$etalonRoutes = $this->loadEtalonRoutesInfo('annotated_users_controller.yml');
9595

9696
$this->assertTrue($collection instanceof RestRouteCollection);
97-
$this->assertEquals(23, count($collection->all()));
97+
$this->assertEquals(24, count($collection->all()));
9898

9999
foreach ($etalonRoutes as $name => $params) {
100100
$route = $collection->get($name);
@@ -107,8 +107,14 @@ public function testAnnotatedUsersFixture()
107107
$this->assertEquals($params['condition'], $route->getCondition(), 'condition failed to match for '.$name);
108108
}
109109

110+
if (isset($params['options'])) {
111+
foreach ($params['options'] as $option => $value) {
112+
$this->assertEquals($value, $route->getOption($option));
113+
}
114+
}
110115
}
111116
}
117+
112118
/**
113119
* Test that annotated UsersController RESTful class gets parsed correctly with condition option (expression-language).
114120
*/

0 commit comments

Comments
 (0)