diff options
Diffstat (limited to 'tests/front/controller/visitor/TagCloudControllerTest.php')
-rw-r--r-- | tests/front/controller/visitor/TagCloudControllerTest.php | 74 |
1 files changed, 43 insertions, 31 deletions
diff --git a/tests/front/controller/visitor/TagCloudControllerTest.php b/tests/front/controller/visitor/TagCloudControllerTest.php index 9a6a4bc0..9305612e 100644 --- a/tests/front/controller/visitor/TagCloudControllerTest.php +++ b/tests/front/controller/visitor/TagCloudControllerTest.php | |||
@@ -4,8 +4,8 @@ declare(strict_types=1); | |||
4 | 4 | ||
5 | namespace Shaarli\Front\Controller\Visitor; | 5 | namespace Shaarli\Front\Controller\Visitor; |
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Shaarli\Bookmark\BookmarkFilter; | 7 | use Shaarli\Bookmark\BookmarkFilter; |
8 | use Shaarli\TestCase; | ||
9 | use Slim\Http\Request; | 9 | use Slim\Http\Request; |
10 | use Slim\Http\Response; | 10 | use Slim\Http\Response; |
11 | 11 | ||
@@ -53,14 +53,16 @@ class TagCloudControllerTest extends TestCase | |||
53 | 53 | ||
54 | // Make sure that PluginManager hook is triggered | 54 | // Make sure that PluginManager hook is triggered |
55 | $this->container->pluginManager | 55 | $this->container->pluginManager |
56 | ->expects(static::at(0)) | 56 | ->expects(static::atLeastOnce()) |
57 | ->method('executeHooks') | 57 | ->method('executeHooks') |
58 | ->withConsecutive(['render_tagcloud']) | ||
58 | ->willReturnCallback(function (string $hook, array $data, array $param): array { | 59 | ->willReturnCallback(function (string $hook, array $data, array $param): array { |
59 | static::assertSame('render_tagcloud', $hook); | 60 | if ('render_tagcloud' === $hook) { |
60 | static::assertSame('', $data['search_tags']); | 61 | static::assertSame('', $data['search_tags']); |
61 | static::assertCount(3, $data['tags']); | 62 | static::assertCount(3, $data['tags']); |
62 | 63 | ||
63 | static::assertArrayHasKey('loggedin', $param); | 64 | static::assertArrayHasKey('loggedin', $param); |
65 | } | ||
64 | 66 | ||
65 | return $data; | 67 | return $data; |
66 | }) | 68 | }) |
@@ -124,14 +126,16 @@ class TagCloudControllerTest extends TestCase | |||
124 | 126 | ||
125 | // Make sure that PluginManager hook is triggered | 127 | // Make sure that PluginManager hook is triggered |
126 | $this->container->pluginManager | 128 | $this->container->pluginManager |
127 | ->expects(static::at(0)) | 129 | ->expects(static::atLeastOnce()) |
128 | ->method('executeHooks') | 130 | ->method('executeHooks') |
131 | ->withConsecutive(['render_tagcloud']) | ||
129 | ->willReturnCallback(function (string $hook, array $data, array $param): array { | 132 | ->willReturnCallback(function (string $hook, array $data, array $param): array { |
130 | static::assertSame('render_tagcloud', $hook); | 133 | if ('render_tagcloud' === $hook) { |
131 | static::assertSame('ghi def', $data['search_tags']); | 134 | static::assertSame('ghi def', $data['search_tags']); |
132 | static::assertCount(1, $data['tags']); | 135 | static::assertCount(1, $data['tags']); |
133 | 136 | ||
134 | static::assertArrayHasKey('loggedin', $param); | 137 | static::assertArrayHasKey('loggedin', $param); |
138 | } | ||
135 | 139 | ||
136 | return $data; | 140 | return $data; |
137 | }) | 141 | }) |
@@ -175,14 +179,16 @@ class TagCloudControllerTest extends TestCase | |||
175 | 179 | ||
176 | // Make sure that PluginManager hook is triggered | 180 | // Make sure that PluginManager hook is triggered |
177 | $this->container->pluginManager | 181 | $this->container->pluginManager |
178 | ->expects(static::at(0)) | 182 | ->expects(static::atLeastOnce()) |
179 | ->method('executeHooks') | 183 | ->method('executeHooks') |
184 | ->withConsecutive(['render_tagcloud']) | ||
180 | ->willReturnCallback(function (string $hook, array $data, array $param): array { | 185 | ->willReturnCallback(function (string $hook, array $data, array $param): array { |
181 | static::assertSame('render_tagcloud', $hook); | 186 | if ('render_tagcloud' === $hook) { |
182 | static::assertSame('', $data['search_tags']); | 187 | static::assertSame('', $data['search_tags']); |
183 | static::assertCount(0, $data['tags']); | 188 | static::assertCount(0, $data['tags']); |
184 | 189 | ||
185 | static::assertArrayHasKey('loggedin', $param); | 190 | static::assertArrayHasKey('loggedin', $param); |
191 | } | ||
186 | 192 | ||
187 | return $data; | 193 | return $data; |
188 | }) | 194 | }) |
@@ -227,14 +233,16 @@ class TagCloudControllerTest extends TestCase | |||
227 | 233 | ||
228 | // Make sure that PluginManager hook is triggered | 234 | // Make sure that PluginManager hook is triggered |
229 | $this->container->pluginManager | 235 | $this->container->pluginManager |
230 | ->expects(static::at(0)) | 236 | ->expects(static::atLeastOnce()) |
231 | ->method('executeHooks') | 237 | ->method('executeHooks') |
238 | ->withConsecutive(['render_taglist']) | ||
232 | ->willReturnCallback(function (string $hook, array $data, array $param): array { | 239 | ->willReturnCallback(function (string $hook, array $data, array $param): array { |
233 | static::assertSame('render_taglist', $hook); | 240 | if ('render_taglist' === $hook) { |
234 | static::assertSame('', $data['search_tags']); | 241 | static::assertSame('', $data['search_tags']); |
235 | static::assertCount(3, $data['tags']); | 242 | static::assertCount(3, $data['tags']); |
236 | 243 | ||
237 | static::assertArrayHasKey('loggedin', $param); | 244 | static::assertArrayHasKey('loggedin', $param); |
245 | } | ||
238 | 246 | ||
239 | return $data; | 247 | return $data; |
240 | }) | 248 | }) |
@@ -297,14 +305,16 @@ class TagCloudControllerTest extends TestCase | |||
297 | 305 | ||
298 | // Make sure that PluginManager hook is triggered | 306 | // Make sure that PluginManager hook is triggered |
299 | $this->container->pluginManager | 307 | $this->container->pluginManager |
300 | ->expects(static::at(0)) | 308 | ->expects(static::atLeastOnce()) |
301 | ->method('executeHooks') | 309 | ->method('executeHooks') |
310 | ->withConsecutive(['render_taglist']) | ||
302 | ->willReturnCallback(function (string $hook, array $data, array $param): array { | 311 | ->willReturnCallback(function (string $hook, array $data, array $param): array { |
303 | static::assertSame('render_taglist', $hook); | 312 | if ('render_taglist' === $hook) { |
304 | static::assertSame('ghi def', $data['search_tags']); | 313 | static::assertSame('ghi def', $data['search_tags']); |
305 | static::assertCount(1, $data['tags']); | 314 | static::assertCount(1, $data['tags']); |
306 | 315 | ||
307 | static::assertArrayHasKey('loggedin', $param); | 316 | static::assertArrayHasKey('loggedin', $param); |
317 | } | ||
308 | 318 | ||
309 | return $data; | 319 | return $data; |
310 | }) | 320 | }) |
@@ -344,14 +354,16 @@ class TagCloudControllerTest extends TestCase | |||
344 | 354 | ||
345 | // Make sure that PluginManager hook is triggered | 355 | // Make sure that PluginManager hook is triggered |
346 | $this->container->pluginManager | 356 | $this->container->pluginManager |
347 | ->expects(static::at(0)) | 357 | ->expects(static::atLeastOnce()) |
348 | ->method('executeHooks') | 358 | ->method('executeHooks') |
359 | ->withConsecutive(['render_taglist']) | ||
349 | ->willReturnCallback(function (string $hook, array $data, array $param): array { | 360 | ->willReturnCallback(function (string $hook, array $data, array $param): array { |
350 | static::assertSame('render_taglist', $hook); | 361 | if ('render_taglist' === $hook) { |
351 | static::assertSame('', $data['search_tags']); | 362 | static::assertSame('', $data['search_tags']); |
352 | static::assertCount(0, $data['tags']); | 363 | static::assertCount(0, $data['tags']); |
353 | 364 | ||
354 | static::assertArrayHasKey('loggedin', $param); | 365 | static::assertArrayHasKey('loggedin', $param); |
366 | } | ||
355 | 367 | ||
356 | return $data; | 368 | return $data; |
357 | }) | 369 | }) |