@@ 49-82 (lines=34) @@ | ||
46 | /** |
|
47 | * @dataProvider requestMethodProvider |
|
48 | */ |
|
49 | public function testShouldRespondOkWithoutTrailingSlash($method) |
|
50 | { |
|
51 | $app = new Application(); |
|
52 | ||
53 | $app->match('/foo/', function () { |
|
54 | return 'hunter42'; |
|
55 | })->method($method); |
|
56 | ||
57 | $app->match('/foo/bar/', function () { |
|
58 | return 'What\'s the question?'; |
|
59 | })->method($method); |
|
60 | ||
61 | $app->match('/foo/bar/baz/', function () { |
|
62 | return 'Fizz Buzz'; |
|
63 | })->method($method); |
|
64 | ||
65 | $app->register(new TrailingSlashControllerProvider()); |
|
66 | $app->mount('/', new TrailingSlashControllerProvider()); |
|
67 | ||
68 | $request = Request::create('/foo', $method); |
|
69 | $response = $app->handle($request); |
|
70 | ||
71 | $this->assertEquals(200, $response->getStatusCode()); |
|
72 | ||
73 | $request = Request::create('/foo/bar', $method); |
|
74 | $response = $app->handle($request); |
|
75 | ||
76 | $this->assertEquals(200, $response->getStatusCode()); |
|
77 | ||
78 | $request = Request::create('/foo/bar/baz', $method); |
|
79 | $response = $app->handle($request); |
|
80 | ||
81 | $this->assertEquals(200, $response->getStatusCode()); |
|
82 | } |
|
83 | ||
84 | /** |
|
85 | * This just shows that the mount order for the controller provider doesn't |
|
@@ 90-123 (lines=34) @@ | ||
87 | * |
|
88 | * @dataProvider requestMethodProvider |
|
89 | */ |
|
90 | public function testShouldRespondOkWithoutTrailingSlashWhenMountedFirst($method) |
|
91 | { |
|
92 | $app = new Application(); |
|
93 | ||
94 | $app->register(new TrailingSlashControllerProvider()); |
|
95 | $app->mount('/', new TrailingSlashControllerProvider()); |
|
96 | ||
97 | $app->match('/foo/', function () { |
|
98 | return 'hunter42'; |
|
99 | })->method($method); |
|
100 | ||
101 | $app->match('/foo/bar/', function () { |
|
102 | return 'What\'s the question?'; |
|
103 | })->method($method); |
|
104 | ||
105 | $app->match('/foo/bar/baz/', function () { |
|
106 | return 'Fizz Buzz'; |
|
107 | })->method($method); |
|
108 | ||
109 | $request = Request::create('/foo', $method); |
|
110 | $response = $app->handle($request); |
|
111 | ||
112 | $this->assertEquals(200, $response->getStatusCode()); |
|
113 | ||
114 | $request = Request::create('/foo/bar', $method); |
|
115 | $response = $app->handle($request); |
|
116 | ||
117 | $this->assertEquals(200, $response->getStatusCode()); |
|
118 | ||
119 | $request = Request::create('/foo/bar/baz', $method); |
|
120 | $response = $app->handle($request); |
|
121 | ||
122 | $this->assertEquals(200, $response->getStatusCode()); |
|
123 | } |
|
124 | ||
125 | /** |
|
126 | * This just shows that the controller provider is compatiable with other |