diff options
Diffstat (limited to 'tests/container/ContainerBuilderTest.php')
-rw-r--r-- | tests/container/ContainerBuilderTest.php | 45 |
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; | |||
7 | use PHPUnit\Framework\TestCase; | 7 | use PHPUnit\Framework\TestCase; |
8 | use Shaarli\Bookmark\BookmarkServiceInterface; | 8 | use Shaarli\Bookmark\BookmarkServiceInterface; |
9 | use Shaarli\Config\ConfigManager; | 9 | use Shaarli\Config\ConfigManager; |
10 | use Shaarli\Feed\FeedBuilder; | ||
11 | use Shaarli\Formatter\FormatterFactory; | ||
12 | use Shaarli\Front\Controller\Visitor\ErrorController; | ||
10 | use Shaarli\History; | 13 | use Shaarli\History; |
14 | use Shaarli\Http\HttpAccess; | ||
15 | use Shaarli\Netscape\NetscapeBookmarkUtils; | ||
16 | use Shaarli\Plugin\PluginManager; | ||
11 | use Shaarli\Render\PageBuilder; | 17 | use Shaarli\Render\PageBuilder; |
18 | use Shaarli\Render\PageCacheManager; | ||
19 | use Shaarli\Security\CookieManager; | ||
12 | use Shaarli\Security\LoginManager; | 20 | use Shaarli\Security\LoginManager; |
13 | use Shaarli\Security\SessionManager; | 21 | use Shaarli\Security\SessionManager; |
22 | use Shaarli\Thumbnailer; | ||
23 | use Shaarli\Updater\Updater; | ||
24 | use Slim\Http\Environment; | ||
14 | 25 | ||
15 | class ContainerBuilderTest extends TestCase | 26 | class 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 | } |