Skip to content

Commit

Permalink
tests(kernel): add tests for Leevel\Kernel\Bootstrap\LoadOption
Browse files Browse the repository at this point in the history
  • Loading branch information
doyouhaobaby committed Nov 1, 2020
1 parent e10afee commit 001d844
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tests/Kernel/Bootstrap/LoadOptionTest.php
Expand Up @@ -26,6 +26,7 @@
use Leevel\Kernel\App as Apps;
use Leevel\Kernel\Bootstrap\LoadOption;
use Leevel\Kernel\IApp;
use Leevel\Option\Option;
use Tests\TestCase;

/**
Expand Down Expand Up @@ -92,7 +93,7 @@ protected function tearDown(): void
*/
public function testBaseUse(): void
{
$bootstrap = new LoadOption();
$bootstrap = new LoadOption1();

$container = Container::singletons();
$app = new App3($container, $appPath = __DIR__.'/app');
Expand All @@ -106,7 +107,7 @@ public function testBaseUse(): void
$this->assertFalse($app->isCachedOption());
$this->assertSame($appPath.'/option', $app->optionPath());

$this->assertNull($bootstrap->handle($app, true));
$this->assertNull($bootstrap->handle($app));

$option = $container->make('option');

Expand Down Expand Up @@ -135,7 +136,7 @@ public function testWithRuntimeEnv(): void
{
putenv('RUNTIME_ENVIRONMENT=fooenv');

$bootstrap = new LoadOption();
$bootstrap = new LoadOption1();

$container = Container::singletons();
$app = new App3($container, $appPath = __DIR__.'/app');
Expand All @@ -149,7 +150,7 @@ public function testWithRuntimeEnv(): void
$this->assertFalse($app->isCachedOption());
$this->assertSame($appPath.'/option', $app->optionPath());

$this->assertNull($bootstrap->handle($app, true));
$this->assertNull($bootstrap->handle($app));

$option = $container->make('option');

Expand All @@ -168,7 +169,7 @@ public function testWithRuntimeEnvNotFound(): void

putenv('RUNTIME_ENVIRONMENT=notfoundenv');

$bootstrap = new LoadOption();
$bootstrap = new LoadOption1();

$container = Container::singletons();
$app = new App3($container, $appPath);
Expand All @@ -182,7 +183,7 @@ public function testWithRuntimeEnvNotFound(): void
$this->assertFalse($app->isCachedOption());
$this->assertSame($appPath.'/option', $app->optionPath());

$bootstrap->handle($app, true);
$bootstrap->handle($app);
}

/**
Expand All @@ -204,7 +205,7 @@ public function testWithRuntimeEnvNotFound(): void
*/
public function testLoadCached(): void
{
$bootstrap = new LoadOption();
$bootstrap = new LoadOption1();

$container = Container::singletons();
$app = new App3($container, $appPath = __DIR__.'/app');
Expand All @@ -223,7 +224,7 @@ public function testLoadCached(): void

$this->assertTrue($app->isCachedOption());

$this->assertNull($bootstrap->handle($app, true));
$this->assertNull($bootstrap->handle($app));

$option = $container->make('option');

Expand All @@ -240,3 +241,10 @@ protected function registerBaseProvider(): void
{
}
}

class LoadOption1 extends LoadOption
{
protected function initialization(Option $option): void
{
}
}

0 comments on commit 001d844

Please sign in to comment.