mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°7870 ✅ Prerequisites to test portal services (instantiate a symfony service)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Sources\Controller;
|
||||
|
||||
use Combodo\iTop\Portal\Controller\AggregatePageBrickController;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
|
||||
class BootSymfonyKernelTest extends ItopDataTestCase
|
||||
{
|
||||
public function testInstantiateServiceWithAnExplicitCallToBootTheKernel()
|
||||
{
|
||||
$this->SetKernelClass(\Combodo\iTop\Portal\Kernel::class);
|
||||
self::bootKernel();
|
||||
$controller = static::getContainer()->get(AggregatePageBrickController::class);
|
||||
|
||||
$this->assertInstanceOf(AggregatePageBrickController::class, $controller);
|
||||
}
|
||||
|
||||
public function testInstantiateServiceWithAnAutomaticKernelBoot()
|
||||
{
|
||||
$this->SetKernelClass(\Combodo\iTop\Portal\Kernel::class);
|
||||
$controller = static::getContainer()->get(AggregatePageBrickController::class);
|
||||
|
||||
$this->assertInstanceOf(AggregatePageBrickController::class, $controller);
|
||||
}
|
||||
|
||||
public function testUnspecifiedKernelClassThrowsAnException()
|
||||
{
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('static::SetKernelClass() must be called before booting the kernel');
|
||||
|
||||
static::getContainer();
|
||||
}
|
||||
|
||||
public function testTwoDifferentKernelsCanBeStartedConsecutively()
|
||||
{
|
||||
self::markTestSkipped('This test is still failing: the second kernel container does not find the requested service');
|
||||
|
||||
$this->SetKernelClass(\Combodo\iTop\Kernel::class);
|
||||
self::bootKernel();
|
||||
|
||||
$this->SetKernelClass(\Combodo\iTop\Portal\Kernel::class);
|
||||
self::bootKernel();
|
||||
$controller = static::getContainer()->get(AggregatePageBrickController::class);
|
||||
|
||||
$this->assertInstanceOf(AggregatePageBrickController::class, $controller);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user