2020-01-18 17:50:11 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Shaarli\Container;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Shaarli\Bookmark\BookmarkServiceInterface;
|
|
|
|
use Shaarli\Config\ConfigManager;
|
2020-01-26 11:15:15 +01:00
|
|
|
use Shaarli\Formatter\FormatterFactory;
|
2020-01-18 17:50:11 +01:00
|
|
|
use Shaarli\History;
|
|
|
|
use Shaarli\Render\PageBuilder;
|
|
|
|
use Shaarli\Security\LoginManager;
|
|
|
|
use Shaarli\Security\SessionManager;
|
|
|
|
|
|
|
|
class ContainerBuilderTest extends TestCase
|
|
|
|
{
|
|
|
|
/** @var ConfigManager */
|
|
|
|
protected $conf;
|
|
|
|
|
|
|
|
/** @var SessionManager */
|
|
|
|
protected $sessionManager;
|
|
|
|
|
|
|
|
/** @var LoginManager */
|
|
|
|
protected $loginManager;
|
|
|
|
|
|
|
|
/** @var ContainerBuilder */
|
|
|
|
protected $containerBuilder;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
$this->conf = new ConfigManager('tests/utils/config/configJson');
|
|
|
|
$this->sessionManager = $this->createMock(SessionManager::class);
|
2020-01-26 11:15:15 +01:00
|
|
|
|
2020-01-18 17:50:11 +01:00
|
|
|
$this->loginManager = $this->createMock(LoginManager::class);
|
2020-01-26 11:15:15 +01:00
|
|
|
$this->loginManager->method('isLoggedIn')->willReturn(true);
|
2020-01-18 17:50:11 +01:00
|
|
|
|
|
|
|
$this->containerBuilder = new ContainerBuilder($this->conf, $this->sessionManager, $this->loginManager);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testBuildContainer(): void
|
|
|
|
{
|
|
|
|
$container = $this->containerBuilder->build();
|
|
|
|
|
|
|
|
static::assertInstanceOf(ConfigManager::class, $container->conf);
|
|
|
|
static::assertInstanceOf(SessionManager::class, $container->sessionManager);
|
|
|
|
static::assertInstanceOf(LoginManager::class, $container->loginManager);
|
|
|
|
static::assertInstanceOf(History::class, $container->history);
|
|
|
|
static::assertInstanceOf(BookmarkServiceInterface::class, $container->bookmarkService);
|
|
|
|
static::assertInstanceOf(PageBuilder::class, $container->pageBuilder);
|
2020-01-26 11:15:15 +01:00
|
|
|
static::assertInstanceOf(FormatterFactory::class, $container->formatterFactory);
|
2020-01-18 17:50:11 +01:00
|
|
|
}
|
|
|
|
}
|