diff options
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 | } |