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