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