12
12
namespace Symfony \Component \Routing \Tests \Loader ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Component \Routing \Alias ;
15
16
use Symfony \Component \Routing \Loader \AnnotationClassLoader ;
16
17
use Symfony \Component \Routing \Tests \Fixtures \AnnotationFixtures \AbstractClassController ;
17
18
@@ -55,6 +56,7 @@ public function testSimplePathRoute()
55
56
$ routes = $ this ->loader ->load ($ this ->getNamespace ().'\ActionPathController ' );
56
57
$ this ->assertCount (1 , $ routes );
57
58
$ this ->assertEquals ('/path ' , $ routes ->get ('action ' )->getPath ());
59
+ $ this ->assertEquals (new Alias ('action ' ), $ routes ->getAlias ($ this ->getNamespace ().'\ActionPathController::action ' ));
58
60
}
59
61
60
62
public function testRequirementsWithoutPlaceholderName ()
@@ -72,6 +74,19 @@ public function testInvokableControllerLoader()
72
74
$ this ->assertEquals ('/here ' , $ routes ->get ('lol ' )->getPath ());
73
75
$ this ->assertEquals (['GET ' , 'POST ' ], $ routes ->get ('lol ' )->getMethods ());
74
76
$ this ->assertEquals (['https ' ], $ routes ->get ('lol ' )->getSchemes ());
77
+ $ this ->assertEquals (new Alias ('lol ' ), $ routes ->getAlias ($ this ->getNamespace ().'\InvokableController ' ));
78
+ $ this ->assertEquals (new Alias ('lol ' ), $ routes ->getAlias ($ this ->getNamespace ().'\InvokableController::__invoke ' ));
79
+ }
80
+
81
+ public function testInvokableMethodControllerLoader ()
82
+ {
83
+ $ routes = $ this ->loader ->load ($ this ->getNamespace ().'\InvokableMethodController ' );
84
+ $ this ->assertCount (1 , $ routes );
85
+ $ this ->assertEquals ('/here ' , $ routes ->get ('lol ' )->getPath ());
86
+ $ this ->assertEquals (['GET ' , 'POST ' ], $ routes ->get ('lol ' )->getMethods ());
87
+ $ this ->assertEquals (['https ' ], $ routes ->get ('lol ' )->getSchemes ());
88
+ $ this ->assertEquals (new Alias ('lol ' ), $ routes ->getAlias ($ this ->getNamespace ().'\InvokableMethodController ' ));
99D5
tr>
89
+ $ this ->assertEquals (new Alias ('lol ' ), $ routes ->getAlias ($ this ->getNamespace ().'\InvokableMethodController::__invoke ' ));
75
90
}
76
91
77
92
public function testInvokableLocalizedControllerLoading ()
@@ -119,6 +134,8 @@ public function testMethodActionControllers()
119
134
$ this ->assertSame (['put ' , 'post ' ], array_keys ($ routes ->all ()));
120
135
$ this ->assertEquals ('/the/path ' , $ routes ->get ('put ' )->getPath ());
121
136
$ this ->assertEquals ('/the/path ' , $ routes ->get ('post ' )->getPath ());
137
+ $ this ->assertEquals (new Alias ('post ' ), $ routes ->getAlias ($ this ->getNamespace ().'\MethodActionControllers::post ' ));
138
+ $ this ->assertEquals (new Alias ('put ' ), $ routes ->getAlias ($ this ->getNamespace ().'\MethodActionControllers::put ' ));
122
139
}
123
140
124
141
public function testInvokableClassRouteLoadWithMethodAnnotation ()
0 commit comments