diff --git a/flight/core/Dispatcher.php b/flight/core/Dispatcher.php
index 2841dd7..6a167a8 100644
--- a/flight/core/Dispatcher.php
+++ b/flight/core/Dispatcher.php
@@ -8,7 +8,6 @@ use Closure;
use Exception;
use flight\Engine;
use InvalidArgumentException;
-use ReflectionClass;
use TypeError;
/**
diff --git a/tests/DispatcherTest.php b/tests/DispatcherTest.php
index f2f3107..d4e1ca1 100644
--- a/tests/DispatcherTest.php
+++ b/tests/DispatcherTest.php
@@ -277,21 +277,27 @@ class DispatcherTest extends TestCase
public function testExecuteStringClassDefaultContainer(): void
{
- $this->dispatcher->setEngine(new Engine());
+ $engine = new Engine();
+ $engine->set('test_me_out', 'You got it boss!');
+ $this->dispatcher->setEngine($engine);
$result = $this->dispatcher->execute(ContainerDefault::class . '->testTheContainer');
$this->assertSame('You got it boss!', $result);
}
public function testExecuteStringClassDefaultContainerDoubleColon(): void
{
- $this->dispatcher->setEngine(new Engine());
+ $engine = new Engine();
+ $engine->set('test_me_out', 'You got it boss!');
+ $this->dispatcher->setEngine($engine);
$result = $this->dispatcher->execute(ContainerDefault::class . '::testTheContainer');
$this->assertSame('You got it boss!', $result);
}
public function testExecuteStringClassDefaultContainerArraySyntax(): void
{
- $this->dispatcher->setEngine(new Engine());
+ $engine = new Engine();
+ $engine->set('test_me_out', 'You got it boss!');
+ $this->dispatcher->setEngine($engine);
$result = $this->dispatcher->execute([ ContainerDefault::class, 'testTheContainer' ]);
$this->assertSame('You got it boss!', $result);
}
diff --git a/tests/EngineTest.php b/tests/EngineTest.php
index b79e344..a8d58ef 100644
--- a/tests/EngineTest.php
+++ b/tests/EngineTest.php
@@ -13,6 +13,7 @@ use flight\util\Collection;
use PDOException;
use PHPUnit\Framework\TestCase;
use tests\classes\Container;
+use tests\classes\ContainerDefault;
// phpcs:ignoreFile PSR2.Methods.MethodDeclaration.Underscore
class EngineTest extends TestCase
@@ -719,6 +720,26 @@ class EngineTest extends TestCase
$this->expectOutputString('Yay! I injected a PdoWrapper, and it returned the number 5 from the database!');
}
+ public function testContainerDiceFlightEngine() {
+ $engine = new Engine();
+ $engine->set('test_me_out', 'You got it boss!');
+ $dice = new \Dice\Dice();
+ $dice = $dice->addRule('*', [
+ 'substitutions' => [
+ Engine::class => $engine
+ ]
+ ]);
+ $engine->registerContainerHandler(function ($class, $params) use ($dice) {
+ return $dice->create($class, $params);
+ });
+
+ $engine->route('/container', ContainerDefault::class.'->echoTheContainer');
+ $engine->request()->url = '/container';
+ $engine->start();
+
+ $this->expectOutputString('You got it boss!');
+ }
+
public function testContainerDicePdoWrapperTestBadParams() {
$engine = new Engine();
$dice = new \Dice\Dice();
diff --git a/tests/classes/ContainerDefault.php b/tests/classes/ContainerDefault.php
index 183d287..a71ff1f 100644
--- a/tests/classes/ContainerDefault.php
+++ b/tests/classes/ContainerDefault.php
@@ -12,7 +12,6 @@ class ContainerDefault
public function __construct(Engine $engine)
{
- $engine->set('test_me_out', 'You got it boss!');
$this->app = $engine;
}
@@ -21,6 +20,11 @@ class ContainerDefault
return $this->app->get('test_me_out');
}
+ public function echoTheContainer()
+ {
+ echo $this->app->get('test_me_out');
+ }
+
public function testUi()
{
echo 'Route text: The container successfully injected a value into the engine! Engine class: ' . get_class($this->app) . ' test_me_out Value: ' . $this->app->get('test_me_out') . '';
diff --git a/tests/server/index.php b/tests/server/index.php
index 8417759..769dc0c 100644
--- a/tests/server/index.php
+++ b/tests/server/index.php
@@ -144,6 +144,7 @@ Flight::group('', function () {
echo 'Route text: This route status is that it ' . ($id === 'before/after' ? 'succeeded' : 'failed') . ' URL Param: ' . $id . '';
});
+ Flight::set('test_me_out', 'You got it boss!'); // used in /no-container route
Flight::route('/no-container', ContainerDefault::class . '->testUi');
Flight::route('/dice', Container::class . '->testThePdoWrapper');
}, [ new LayoutMiddleware() ]);