From 0892d45c2050b601f70b6d7ce5672cfc40452441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Wed, 21 Sep 2016 11:29:24 +0200 Subject: [PATCH] Fix bug with sub-components --- src/Application/ParameterFinder.php | 2 +- tests/unit/src/Classes/TestComponent.php | 7 +++++++ tests/unit/src/ParameterFinderTest.php | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Application/ParameterFinder.php b/src/Application/ParameterFinder.php index 2d5242e..1e5d62a 100644 --- a/src/Application/ParameterFinder.php +++ b/src/Application/ParameterFinder.php @@ -201,7 +201,7 @@ private function createReflection(PresenterComponentReflection $reflection, $com } return isset($subComponent) - ? $this->createReflection(new ClassType($class), $subComponent) + ? $this->createReflection(new PresenterComponentReflection($class), $subComponent) : new PresenterComponentReflection($class); } } diff --git a/tests/unit/src/Classes/TestComponent.php b/tests/unit/src/Classes/TestComponent.php index 6ffb1e9..710f5ef 100644 --- a/tests/unit/src/Classes/TestComponent.php +++ b/tests/unit/src/Classes/TestComponent.php @@ -25,4 +25,11 @@ final public function __construct() public function handleTestHandle(Class6 $handleEntity) { } + + /** + * @return TestComponent + */ + public function createComponentSub() + { + } } diff --git a/tests/unit/src/ParameterFinderTest.php b/tests/unit/src/ParameterFinderTest.php index 6523271..6142ed9 100644 --- a/tests/unit/src/ParameterFinderTest.php +++ b/tests/unit/src/ParameterFinderTest.php @@ -99,6 +99,22 @@ public function testComponent() ], $this->finder->getMapping($request)); } + public function testSubComponent() + { + $request = new Request('', 'GET', [ + 'action' => 'testAction', + 'do' => 'component-sub-testHandle', + 'component-sub-persistent' => 1, + ]); + $this->assertEquals([ + 'persistent1' => $this->createInfoObject('Tests\Unit\Classes\Class1', true), + 'actionEntity' => $this->createInfoObject('Tests\Unit\Classes\Class2', false), + 'component-sub-persistent' => $this->createInfoObject('Tests\Unit\Classes\Class5', true), + 'component-sub-handleEntity' => $this->createInfoObject('Tests\Unit\Classes\Class6', false), + 'persistent2' => $this->createInfoObject('string', true), + ], $this->finder->getMapping($request)); + } + public function testNamelessComponent() { $request = new Request('', 'GET', [