aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/container/ContainerBuilderTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
committerArthurHoaro <arthur@hoa.ro>2020-10-13 12:05:08 +0200
commitb6f678a5a1d15acf284ebcec16c905e976671ce1 (patch)
tree33c7da831482ed79c44896ef19c73c72ada84f2e /tests/container/ContainerBuilderTest.php
parentb14687036b9b800681197f51fdc47e62f0c88e2e (diff)
parent1c1520b6b98ab20201bfe15577782a52320339df (diff)
downloadShaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.gz
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.tar.zst
Shaarli-b6f678a5a1d15acf284ebcec16c905e976671ce1.zip
Merge branch 'v0.12' into latest
Diffstat (limited to 'tests/container/ContainerBuilderTest.php')
-rw-r--r--tests/container/ContainerBuilderTest.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/container/ContainerBuilderTest.php b/tests/container/ContainerBuilderTest.php
new file mode 100644
index 00000000..5d52daef
--- /dev/null
+++ b/tests/container/ContainerBuilderTest.php
@@ -0,0 +1,88 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Container;
6
7use Shaarli\Bookmark\BookmarkServiceInterface;
8use Shaarli\Config\ConfigManager;
9use Shaarli\Feed\FeedBuilder;
10use Shaarli\Formatter\FormatterFactory;
11use Shaarli\Front\Controller\Visitor\ErrorController;
12use Shaarli\Front\Controller\Visitor\ErrorNotFoundController;
13use Shaarli\History;
14use Shaarli\Http\HttpAccess;
15use Shaarli\Netscape\NetscapeBookmarkUtils;
16use Shaarli\Plugin\PluginManager;
17use Shaarli\Render\PageBuilder;
18use Shaarli\Render\PageCacheManager;
19use Shaarli\Security\CookieManager;
20use Shaarli\Security\LoginManager;
21use Shaarli\Security\SessionManager;
22use Shaarli\TestCase;
23use Shaarli\Thumbnailer;
24use Shaarli\Updater\Updater;
25use Slim\Http\Environment;
26
27class ContainerBuilderTest extends TestCase
28{
29 /** @var ConfigManager */
30 protected $conf;
31
32 /** @var SessionManager */
33 protected $sessionManager;
34
35 /** @var LoginManager */
36 protected $loginManager;
37
38 /** @var ContainerBuilder */
39 protected $containerBuilder;
40
41 /** @var CookieManager */
42 protected $cookieManager;
43
44 public function setUp(): void
45 {
46 $this->conf = new ConfigManager('tests/utils/config/configJson');
47 $this->sessionManager = $this->createMock(SessionManager::class);
48 $this->cookieManager = $this->createMock(CookieManager::class);
49
50 $this->loginManager = $this->createMock(LoginManager::class);
51 $this->loginManager->method('isLoggedIn')->willReturn(true);
52
53 $this->containerBuilder = new ContainerBuilder(
54 $this->conf,
55 $this->sessionManager,
56 $this->cookieManager,
57 $this->loginManager
58 );
59 }
60
61 public function testBuildContainer(): void
62 {
63 $container = $this->containerBuilder->build();
64
65 static::assertInstanceOf(BookmarkServiceInterface::class, $container->bookmarkService);
66 static::assertInstanceOf(CookieManager::class, $container->cookieManager);
67 static::assertInstanceOf(ConfigManager::class, $container->conf);
68 static::assertInstanceOf(ErrorController::class, $container->errorHandler);
69 static::assertInstanceOf(Environment::class, $container->environment);
70 static::assertInstanceOf(FeedBuilder::class, $container->feedBuilder);
71 static::assertInstanceOf(FormatterFactory::class, $container->formatterFactory);
72 static::assertInstanceOf(History::class, $container->history);
73 static::assertInstanceOf(HttpAccess::class, $container->httpAccess);
74 static::assertInstanceOf(LoginManager::class, $container->loginManager);
75 static::assertInstanceOf(NetscapeBookmarkUtils::class, $container->netscapeBookmarkUtils);
76 static::assertInstanceOf(PageBuilder::class, $container->pageBuilder);
77 static::assertInstanceOf(PageCacheManager::class, $container->pageCacheManager);
78 static::assertInstanceOf(ErrorController::class, $container->phpErrorHandler);
79 static::assertInstanceOf(ErrorNotFoundController::class, $container->notFoundHandler);
80 static::assertInstanceOf(PluginManager::class, $container->pluginManager);
81 static::assertInstanceOf(SessionManager::class, $container->sessionManager);
82 static::assertInstanceOf(Thumbnailer::class, $container->thumbnailer);
83 static::assertInstanceOf(Updater::class, $container->updater);
84
85 // Set by the middleware
86 static::assertNull($container->basePath);
87 }
88}