diff options
Diffstat (limited to 'tests/front/controller/TagCloudControllerTest.php')
-rw-r--r-- | tests/front/controller/TagCloudControllerTest.php | 62 |
1 files changed, 3 insertions, 59 deletions
diff --git a/tests/front/controller/TagCloudControllerTest.php b/tests/front/controller/TagCloudControllerTest.php index 719610d7..8c27900d 100644 --- a/tests/front/controller/TagCloudControllerTest.php +++ b/tests/front/controller/TagCloudControllerTest.php | |||
@@ -6,27 +6,20 @@ namespace Shaarli\Front\Controller; | |||
6 | 6 | ||
7 | use PHPUnit\Framework\TestCase; | 7 | use PHPUnit\Framework\TestCase; |
8 | use Shaarli\Bookmark\BookmarkFilter; | 8 | use Shaarli\Bookmark\BookmarkFilter; |
9 | use Shaarli\Bookmark\BookmarkServiceInterface; | ||
10 | use Shaarli\Config\ConfigManager; | ||
11 | use Shaarli\Container\ShaarliContainer; | ||
12 | use Shaarli\Plugin\PluginManager; | ||
13 | use Shaarli\Render\PageBuilder; | ||
14 | use Shaarli\Security\LoginManager; | ||
15 | use Shaarli\Security\SessionManager; | ||
16 | use Slim\Http\Request; | 9 | use Slim\Http\Request; |
17 | use Slim\Http\Response; | 10 | use Slim\Http\Response; |
18 | 11 | ||
19 | class TagCloudControllerTest extends TestCase | 12 | class TagCloudControllerTest extends TestCase |
20 | { | 13 | { |
21 | /** @var ShaarliContainer */ | 14 | use FrontControllerMockHelper; |
22 | protected $container; | ||
23 | 15 | ||
24 | /** @var TagCloudController */ | 16 | /** @var TagCloudController */ |
25 | protected $controller; | 17 | protected $controller; |
26 | 18 | ||
27 | public function setUp(): void | 19 | public function setUp(): void |
28 | { | 20 | { |
29 | $this->container = $this->createMock(ShaarliContainer::class); | 21 | $this->createContainer(); |
22 | |||
30 | $this->controller = new TagCloudController($this->container); | 23 | $this->controller = new TagCloudController($this->container); |
31 | } | 24 | } |
32 | 25 | ||
@@ -385,53 +378,4 @@ class TagCloudControllerTest extends TestCase | |||
385 | static::assertSame('', $assignedVariables['search_tags']); | 378 | static::assertSame('', $assignedVariables['search_tags']); |
386 | static::assertCount(0, $assignedVariables['tags']); | 379 | static::assertCount(0, $assignedVariables['tags']); |
387 | } | 380 | } |
388 | |||
389 | |||
390 | protected function createValidContainerMockSet(): void | ||
391 | { | ||
392 | $loginManager = $this->createMock(LoginManager::class); | ||
393 | $this->container->loginManager = $loginManager; | ||
394 | |||
395 | $sessionManager = $this->createMock(SessionManager::class); | ||
396 | $this->container->sessionManager = $sessionManager; | ||
397 | |||
398 | // Config | ||
399 | $conf = $this->createMock(ConfigManager::class); | ||
400 | $this->container->conf = $conf; | ||
401 | |||
402 | $this->container->conf->method('get')->willReturnCallback(function (string $parameter, $default) { | ||
403 | return $default; | ||
404 | }); | ||
405 | |||
406 | // PageBuilder | ||
407 | $pageBuilder = $this->createMock(PageBuilder::class); | ||
408 | $pageBuilder | ||
409 | ->method('render') | ||
410 | ->willReturnCallback(function (string $template): string { | ||
411 | return $template; | ||
412 | }) | ||
413 | ; | ||
414 | $this->container->pageBuilder = $pageBuilder; | ||
415 | |||
416 | // Plugin Manager | ||
417 | $pluginManager = $this->createMock(PluginManager::class); | ||
418 | $this->container->pluginManager = $pluginManager; | ||
419 | |||
420 | // BookmarkService | ||
421 | $bookmarkService = $this->createMock(BookmarkServiceInterface::class); | ||
422 | $this->container->bookmarkService = $bookmarkService; | ||
423 | } | ||
424 | |||
425 | protected function assignTemplateVars(array &$variables): void | ||
426 | { | ||
427 | $this->container->pageBuilder | ||
428 | ->expects(static::atLeastOnce()) | ||
429 | ->method('assign') | ||
430 | ->willReturnCallback(function ($key, $value) use (&$variables) { | ||
431 | $variables[$key] = $value; | ||
432 | |||
433 | return $this; | ||
434 | }) | ||
435 | ; | ||
436 | } | ||
437 | } | 381 | } |