first commit
This commit is contained in:
56
tests/Kernel/BootstrapTest.php
Normal file
56
tests/Kernel/BootstrapTest.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Kernel;
|
||||
|
||||
use Netig\Netslim\Kernel\Runtime\Bootstrap;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use ReflectionProperty;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
|
||||
final class BootstrapTest extends TestCase
|
||||
{
|
||||
public function testInitializeInfrastructureReturnsPreloadedContainer(): void
|
||||
{
|
||||
$bootstrap = Bootstrap::create();
|
||||
$container = $this->createStub(ContainerInterface::class);
|
||||
|
||||
$this->setPrivate($bootstrap, 'container', $container);
|
||||
|
||||
self::assertSame($container, $bootstrap->initializeInfrastructure());
|
||||
self::assertSame($container, $bootstrap->getContainer());
|
||||
}
|
||||
|
||||
public function testCreateHttpAppReturnsPreloadedApp(): void
|
||||
{
|
||||
$bootstrap = Bootstrap::create();
|
||||
$app = AppFactory::create();
|
||||
|
||||
$this->setPrivate($bootstrap, 'app', $app);
|
||||
|
||||
self::assertSame($app, $bootstrap->createHttpApp());
|
||||
}
|
||||
|
||||
public function testInitializeReturnsPreloadedApp(): void
|
||||
{
|
||||
$bootstrap = Bootstrap::create();
|
||||
$container = $this->createStub(ContainerInterface::class);
|
||||
$app = AppFactory::create();
|
||||
|
||||
$this->setPrivate($bootstrap, 'container', $container);
|
||||
$this->setPrivate($bootstrap, 'app', $app);
|
||||
|
||||
self::assertSame($app, $bootstrap->initialize());
|
||||
}
|
||||
|
||||
private function setPrivate(Bootstrap $bootstrap, string $property, mixed $value): void
|
||||
{
|
||||
$reflection = new ReflectionProperty($bootstrap, $property);
|
||||
$reflection->setAccessible(true);
|
||||
$reflection->setValue($bootstrap, $value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user