diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-05-20 14:38:31 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-07-23 21:19:21 +0200 |
commit | 893f5159c64e5bcff505c8367e6dc22cc2a7b14d (patch) | |
tree | ba07dc71bb17ef143fb2038fcb68f4bc4a62a090 /tests/front | |
parent | dd09ec52b20b4a548ecf5c847627575e506e3a50 (diff) | |
download | Shaarli-893f5159c64e5bcff505c8367e6dc22cc2a7b14d.tar.gz Shaarli-893f5159c64e5bcff505c8367e6dc22cc2a7b14d.tar.zst Shaarli-893f5159c64e5bcff505c8367e6dc22cc2a7b14d.zip |
Process remove tag endpoint through Slim controller
Diffstat (limited to 'tests/front')
-rw-r--r-- | tests/front/controller/TagControllerTest.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/front/controller/TagControllerTest.php b/tests/front/controller/TagControllerTest.php index 5eea537b..2184cb11 100644 --- a/tests/front/controller/TagControllerTest.php +++ b/tests/front/controller/TagControllerTest.php | |||
@@ -157,4 +157,86 @@ class TagControllerTest extends TestCase | |||
157 | static::assertSame(302, $result->getStatusCode()); | 157 | static::assertSame(302, $result->getStatusCode()); |
158 | static::assertSame(['./'], $result->getHeader('location')); | 158 | static::assertSame(['./'], $result->getHeader('location')); |
159 | } | 159 | } |
160 | |||
161 | public function testRemoveTagWithoutMatchingTag(): void | ||
162 | { | ||
163 | $this->createValidContainerMockSet(); | ||
164 | |||
165 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtags=def']; | ||
166 | |||
167 | $request = $this->createMock(Request::class); | ||
168 | $response = new Response(); | ||
169 | |||
170 | $tags = ['tag' => 'abc']; | ||
171 | |||
172 | $result = $this->controller->removeTag($request, $response, $tags); | ||
173 | |||
174 | static::assertInstanceOf(Response::class, $result); | ||
175 | static::assertSame(302, $result->getStatusCode()); | ||
176 | static::assertSame(['/controller/?searchtags=def'], $result->getHeader('location')); | ||
177 | } | ||
178 | |||
179 | public function testRemoveTagWithoutTagsearch(): void | ||
180 | { | ||
181 | $this->createValidContainerMockSet(); | ||
182 | |||
183 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/']; | ||
184 | |||
185 | $request = $this->createMock(Request::class); | ||
186 | $response = new Response(); | ||
187 | |||
188 | $tags = ['tag' => 'abc']; | ||
189 | |||
190 | $result = $this->controller->removeTag($request, $response, $tags); | ||
191 | |||
192 | static::assertInstanceOf(Response::class, $result); | ||
193 | static::assertSame(302, $result->getStatusCode()); | ||
194 | static::assertSame(['/controller/'], $result->getHeader('location')); | ||
195 | } | ||
196 | |||
197 | public function testRemoveTagWithoutReferer(): void | ||
198 | { | ||
199 | $this->createValidContainerMockSet(); | ||
200 | |||
201 | $request = $this->createMock(Request::class); | ||
202 | $response = new Response(); | ||
203 | |||
204 | $tags = ['tag' => 'abc']; | ||
205 | |||
206 | $result = $this->controller->removeTag($request, $response, $tags); | ||
207 | |||
208 | static::assertInstanceOf(Response::class, $result); | ||
209 | static::assertSame(302, $result->getStatusCode()); | ||
210 | static::assertSame(['./'], $result->getHeader('location')); | ||
211 | } | ||
212 | |||
213 | public function testRemoveTagWithoutTag(): void | ||
214 | { | ||
215 | $this->createValidContainerMockSet(); | ||
216 | |||
217 | $this->container->environment = ['HTTP_REFERER' => 'http://shaarli/controller/?searchtag=abc']; | ||
218 | |||
219 | $request = $this->createMock(Request::class); | ||
220 | $response = new Response(); | ||
221 | |||
222 | $result = $this->controller->removeTag($request, $response, []); | ||
223 | |||
224 | static::assertInstanceOf(Response::class, $result); | ||
225 | static::assertSame(302, $result->getStatusCode()); | ||
226 | static::assertSame(['/controller/?searchtag=abc'], $result->getHeader('location')); | ||
227 | } | ||
228 | |||
229 | public function testRemoveTagWithoutTagWithoutReferer(): void | ||
230 | { | ||
231 | $this->createValidContainerMockSet(); | ||
232 | |||
233 | $request = $this->createMock(Request::class); | ||
234 | $response = new Response(); | ||
235 | |||
236 | $result = $this->controller->removeTag($request, $response, []); | ||
237 | |||
238 | static::assertInstanceOf(Response::class, $result); | ||
239 | static::assertSame(302, $result->getStatusCode()); | ||
240 | static::assertSame(['./'], $result->getHeader('location')); | ||
241 | } | ||
160 | } | 242 | } |