From 47b9dee94e2dea9298c8c5572b1e6def036d49cb Mon Sep 17 00:00:00 2001 From: Oliver Hader Date: Fri, 10 Jan 2020 16:31:24 +0100 Subject: [PATCH] [TASK] Avoid superfluous Reflection invocation in tests Resolves: #90086 Releases: master, 9.5 Change-Id: Ibe5eb0db866933984a07ac5f5b82010a0ae4698b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62845 Tested-by: TYPO3com Tested-by: Daniel Goerz Reviewed-by: Daniel Goerz --- .../Mvc/Controller/ActionControllerTest.php | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerTest.php b/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerTest.php index af9929224086..b6deebfe2ce0 100644 --- a/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Mvc/Controller/ActionControllerTest.php @@ -16,7 +16,6 @@ */ use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Mvc\Controller\Arguments; use TYPO3\CMS\Extbase\Mvc\Web\Request; use TYPO3\CMS\Extbase\Mvc\Web\Response; use TYPO3\CMS\Extbase\Object\ObjectManager; @@ -63,6 +62,12 @@ protected function setUp() $this->controller = $objectManager->get(Fixture\Controller\TestController::class); } + protected function tearDown() + { + unset($this->request, $this->response, $this->controller); + parent::tearDown(); + } + /** * @test */ @@ -75,15 +80,8 @@ public function modelValidatorsAreProperlyResolved() // Test run $this->controller->processRequest($this->request, $this->response); - // Open arguments property - $reflectionClass = new \ReflectionClass($this->controller); - $argumentsProperty = $reflectionClass->getProperty('arguments'); - $argumentsProperty->setAccessible(true); - // Assertions - - /** @var Arguments $arguments */ - $arguments = $argumentsProperty->getValue($this->controller); + $arguments = $this->controller->getControllerContext()->getArguments(); $argument = $arguments->getArgument('fooParam'); /** @var ConjunctionValidator $validator */ @@ -120,15 +118,8 @@ public function customValidatorsAreProperlyResolved() // Test run $this->controller->processRequest($this->request, $this->response); - // Open arguments property - $reflectionClass = new \ReflectionClass($this->controller); - $argumentsProperty = $reflectionClass->getProperty('arguments'); - $argumentsProperty->setAccessible(true); - // Assertions - - /** @var Arguments $arguments */ - $arguments = $argumentsProperty->getValue($this->controller); + $arguments = $this->controller->getControllerContext()->getArguments(); $argument = $arguments->getArgument('barParam'); /** @var ConjunctionValidator $validator */ @@ -168,15 +159,8 @@ public function extbaseValidatorsAreProperlyResolved() // Test run $this->controller->processRequest($this->request, $this->response); - // Open arguments property - $reflectionClass = new \ReflectionClass($this->controller); - $argumentsProperty = $reflectionClass->getProperty('arguments'); - $argumentsProperty->setAccessible(true); - // Assertions - - /** @var Arguments $arguments */ - $arguments = $argumentsProperty->getValue($this->controller); + $arguments = $this->controller->getControllerContext()->getArguments(); $argument = $arguments->getArgument('bazParam'); /** @var ConjunctionValidator $validator */