]> git.immae.eu Git - github/shaarli/Shaarli.git/blame_incremental - tests/container/ContainerBuilderTest.php
Merge pull request #1524 from ArthurHoaro/fix/rss-sticky
[github/shaarli/Shaarli.git] / tests / container / ContainerBuilderTest.php
... / ...
CommitLineData
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Container;
6
7use PHPUnit\Framework\TestCase;
8use Shaarli\Bookmark\BookmarkServiceInterface;
9use Shaarli\Config\ConfigManager;
10use Shaarli\Feed\FeedBuilder;
11use Shaarli\Formatter\FormatterFactory;
12use Shaarli\Front\Controller\Visitor\ErrorController;
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\Thumbnailer;
23use Shaarli\Updater\Updater;
24use Slim\Http\Environment;
25
26class ContainerBuilderTest extends TestCase
27{
28 /** @var ConfigManager */
29 protected $conf;
30
31 /** @var SessionManager */
32 protected $sessionManager;
33
34 /** @var LoginManager */
35 protected $loginManager;
36
37 /** @var ContainerBuilder */
38 protected $containerBuilder;
39
40 /** @var CookieManager */
41 protected $cookieManager;
42
43 public function setUp(): void
44 {
45 $this->conf = new ConfigManager('tests/utils/config/configJson');
46 $this->sessionManager = $this->createMock(SessionManager::class);
47 $this->cookieManager = $this->createMock(CookieManager::class);
48
49 $this->loginManager = $this->createMock(LoginManager::class);
50 $this->loginManager->method('isLoggedIn')->willReturn(true);
51
52 $this->containerBuilder = new ContainerBuilder(
53 $this->conf,
54 $this->sessionManager,
55 $this->cookieManager,
56 $this->loginManager
57 );
58 }
59
60 public function testBuildContainer(): void
61 {
62 $container = $this->containerBuilder->build();
63
64 static::assertInstanceOf(BookmarkServiceInterface::class, $container->bookmarkService);
65 static::assertInstanceOf(CookieManager::class, $container->cookieManager);
66 static::assertInstanceOf(ConfigManager::class, $container->conf);
67 static::assertInstanceOf(ErrorController::class, $container->errorHandler);
68 static::assertInstanceOf(Environment::class, $container->environment);
69 static::assertInstanceOf(FeedBuilder::class, $container->feedBuilder);
70 static::assertInstanceOf(FormatterFactory::class, $container->formatterFactory);
71 static::assertInstanceOf(History::class, $container->history);
72 static::assertInstanceOf(HttpAccess::class, $container->httpAccess);
73 static::assertInstanceOf(LoginManager::class, $container->loginManager);
74 static::assertInstanceOf(NetscapeBookmarkUtils::class, $container->netscapeBookmarkUtils);
75 static::assertInstanceOf(PageBuilder::class, $container->pageBuilder);
76 static::assertInstanceOf(PageCacheManager::class, $container->pageCacheManager);
77 static::assertInstanceOf(ErrorController::class, $container->phpErrorHandler);
78 static::assertInstanceOf(PluginManager::class, $container->pluginManager);
79 static::assertInstanceOf(SessionManager::class, $container->sessionManager);
80 static::assertInstanceOf(Thumbnailer::class, $container->thumbnailer);
81 static::assertInstanceOf(Updater::class, $container->updater);
82
83 // Set by the middleware
84 static::assertNull($container->basePath);
85 }
86}