aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/container/ContainerBuilderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/container/ContainerBuilderTest.php')
-rw-r--r--tests/container/ContainerBuilderTest.php45
1 files changed, 41 insertions, 4 deletions
diff --git a/tests/container/ContainerBuilderTest.php b/tests/container/ContainerBuilderTest.php
index 9b97ed6d..c08010ae 100644
--- a/tests/container/ContainerBuilderTest.php
+++ b/tests/container/ContainerBuilderTest.php
@@ -7,10 +7,21 @@ namespace Shaarli\Container;
7use PHPUnit\Framework\TestCase; 7use PHPUnit\Framework\TestCase;
8use Shaarli\Bookmark\BookmarkServiceInterface; 8use Shaarli\Bookmark\BookmarkServiceInterface;
9use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
10use Shaarli\Feed\FeedBuilder;
11use Shaarli\Formatter\FormatterFactory;
12use Shaarli\Front\Controller\Visitor\ErrorController;
10use Shaarli\History; 13use Shaarli\History;
14use Shaarli\Http\HttpAccess;
15use Shaarli\Netscape\NetscapeBookmarkUtils;
16use Shaarli\Plugin\PluginManager;
11use Shaarli\Render\PageBuilder; 17use Shaarli\Render\PageBuilder;
18use Shaarli\Render\PageCacheManager;
19use Shaarli\Security\CookieManager;
12use Shaarli\Security\LoginManager; 20use Shaarli\Security\LoginManager;
13use Shaarli\Security\SessionManager; 21use Shaarli\Security\SessionManager;
22use Shaarli\Thumbnailer;
23use Shaarli\Updater\Updater;
24use Slim\Http\Environment;
14 25
15class ContainerBuilderTest extends TestCase 26class ContainerBuilderTest extends TestCase
16{ 27{
@@ -26,24 +37,50 @@ class ContainerBuilderTest extends TestCase
26 /** @var ContainerBuilder */ 37 /** @var ContainerBuilder */
27 protected $containerBuilder; 38 protected $containerBuilder;
28 39
40 /** @var CookieManager */
41 protected $cookieManager;
42
29 public function setUp(): void 43 public function setUp(): void
30 { 44 {
31 $this->conf = new ConfigManager('tests/utils/config/configJson'); 45 $this->conf = new ConfigManager('tests/utils/config/configJson');
32 $this->sessionManager = $this->createMock(SessionManager::class); 46 $this->sessionManager = $this->createMock(SessionManager::class);
47 $this->cookieManager = $this->createMock(CookieManager::class);
48
33 $this->loginManager = $this->createMock(LoginManager::class); 49 $this->loginManager = $this->createMock(LoginManager::class);
50 $this->loginManager->method('isLoggedIn')->willReturn(true);
34 51
35 $this->containerBuilder = new ContainerBuilder($this->conf, $this->sessionManager, $this->loginManager); 52 $this->containerBuilder = new ContainerBuilder(
53 $this->conf,
54 $this->sessionManager,
55 $this->cookieManager,
56 $this->loginManager
57 );
36 } 58 }
37 59
38 public function testBuildContainer(): void 60 public function testBuildContainer(): void
39 { 61 {
40 $container = $this->containerBuilder->build(); 62 $container = $this->containerBuilder->build();
41 63
64 static::assertInstanceOf(BookmarkServiceInterface::class, $container->bookmarkService);
65 static::assertInstanceOf(CookieManager::class, $container->cookieManager);
42 static::assertInstanceOf(ConfigManager::class, $container->conf); 66 static::assertInstanceOf(ConfigManager::class, $container->conf);
43 static::assertInstanceOf(SessionManager::class, $container->sessionManager); 67 static::assertInstanceOf(ErrorController::class, $container->errorHandler);
44 static::assertInstanceOf(LoginManager::class, $container->loginManager); 68 static::assertInstanceOf(Environment::class, $container->environment);
69 static::assertInstanceOf(FeedBuilder::class, $container->feedBuilder);
70 static::assertInstanceOf(FormatterFactory::class, $container->formatterFactory);
45 static::assertInstanceOf(History::class, $container->history); 71 static::assertInstanceOf(History::class, $container->history);
46 static::assertInstanceOf(BookmarkServiceInterface::class, $container->bookmarkService); 72 static::assertInstanceOf(HttpAccess::class, $container->httpAccess);
73 static::assertInstanceOf(LoginManager::class, $container->loginManager);
74 static::assertInstanceOf(NetscapeBookmarkUtils::class, $container->netscapeBookmarkUtils);
47 static::assertInstanceOf(PageBuilder::class, $container->pageBuilder); 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);
48 } 85 }
49} 86}