diff --git a/src/Container/ReflectionContainer.php b/src/Container/ReflectionContainer.php index 740118b..ab2d971 100644 --- a/src/Container/ReflectionContainer.php +++ b/src/Container/ReflectionContainer.php @@ -47,6 +47,11 @@ public function get($id) throw new Exception\NotFoundException(sprintf($message, $id)); } + if ($this->container && $this->container->has($id)) + { + return $this->container->get((string) $id); + } + /** @var class-string $id */ $reflection = new \ReflectionClass((string) $id); @@ -57,11 +62,6 @@ public function get($id) return $reflection->newInstanceArgs($arguments); } - if ($this->container && $this->container->has($id)) - { - return $this->container->get((string) $id); - } - return new $id; } diff --git a/tests/Application/ApplicationTestCases.php b/tests/Application/ApplicationTestCases.php index e3f3e6f..3110e00 100644 --- a/tests/Application/ApplicationTestCases.php +++ b/tests/Application/ApplicationTestCases.php @@ -12,6 +12,11 @@ */ class ApplicationTestCases extends Testcase { + /** + * @var string + */ + protected $type = ''; + /** * @var \Rougin\Slytherin\System */ @@ -160,6 +165,11 @@ public function test_response_using_response_interface() */ public function test_response_with_mutated_server_request() { + if ($this->type === 'auryn') + { + $this->markTestSkipped('Dynamic request must be shared again if using Auryn.'); + } + $data = array('test' => 'Hello with request'); $request = $this->request('GET', '/request', $data); diff --git a/tests/Application/AurynContainerTest.php b/tests/Application/AurynContainerTest.php index f7fefed..b87bc9a 100644 --- a/tests/Application/AurynContainerTest.php +++ b/tests/Application/AurynContainerTest.php @@ -15,6 +15,11 @@ */ class AurynContainerTest extends ApplicationTestCases { + /** + * @var string + */ + protected $type = 'auryn'; + /** * @return void */ @@ -31,15 +36,15 @@ protected function doSetUp() $router = $this->router(); + $container->share(new Dispatcher($router)); + $container->alias(System::DISPATCHER, 'Rougin\Slytherin\Routing\Dispatcher'); + $container->share($this->request('GET', '/')); $container->alias(System::REQUEST, 'Rougin\Slytherin\Http\ServerRequest'); $container->share(new Response); $container->alias(System::RESPONSE, 'Rougin\Slytherin\Http\Response'); - $container->share(new Dispatcher($router)); - $container->alias(System::DISPATCHER, 'Rougin\Slytherin\Routing\Dispatcher'); - $container->share(new Middleware); $container->alias(System::MIDDLEWARE, 'Rougin\Slytherin\Middleware\Dispatcher');