[BUGFIX] Incomplete mocks in fluid tests 26/54926/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 3 Dec 2017 20:27:59 +0000 (21:27 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 3 Dec 2017 20:53:24 +0000 (21:53 +0100)
Sanitize some view helper unit tests to not trigger
PHP 7.2 warnings count()'ing non-arrays by proper mocking.

Change-Id: I9929a02a03c9218ab73838f4a214165333d414aa
Resolves: #83213
Releases: 7.6
Reviewed-on: https://review.typo3.org/54926
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/fluid/Tests/Unit/Core/Parser/SyntaxTree/ViewHelperNodeTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/AbstractViewHelperTest.php

index 2cba275..7b9c7ee 100644 (file)
@@ -85,9 +85,10 @@ class ViewHelperNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
      */
     public function childNodeAccessFacetWorksAsExpected()
     {
-        $childNode = $this->getMock(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\TextNode::class, [], ['foo']);
+        $childNode = $this->getMock(\TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\TextNode::class, [], ['prepareArguments']);
 
         $mockViewHelper = $this->getMock(\TYPO3\CMS\Fluid\Tests\Unit\Core\Parser\Fixtures\ChildNodeAccessFacetViewHelper::class, ['setChildNodes', 'initializeArguments', 'render', 'prepareArguments']);
+        $mockViewHelper->expects($this->any())->method('prepareArguments')->willReturn([]);
 
         $viewHelperNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode($mockViewHelper, []);
         $viewHelperNode->addChildNode($childNode);
@@ -104,6 +105,7 @@ class ViewHelperNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $mockViewHelper = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper::class, ['initializeArgumentsAndRender', 'prepareArguments']);
         $mockViewHelper->expects($this->once())->method('initializeArgumentsAndRender');
+        $mockViewHelper->expects($this->any())->method('prepareArguments')->willReturn([]);
 
         $viewHelperNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode($mockViewHelper, []);
 
@@ -140,6 +142,7 @@ class ViewHelperNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $mockViewHelper = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper::class, ['render', 'validateArguments', 'prepareArguments', 'setRenderingContext']);
         $mockViewHelper->expects($this->once())->method('setRenderingContext')->with($this->renderingContext);
+        $mockViewHelper->expects($this->any())->method('prepareArguments')->willReturn([]);
 
         $viewHelperNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode($mockViewHelper, []);
 
@@ -153,6 +156,7 @@ class ViewHelperNodeTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $mockViewHelper = $this->getMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper::class, ['render', 'validateArguments', 'prepareArguments', 'setViewHelperVariableContainer']);
         $mockViewHelper->expects($this->any())->method('render')->will($this->returnValue('String'));
+        $mockViewHelper->expects($this->any())->method('prepareArguments')->willReturn([]);
 
         $viewHelperNode = new \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode($mockViewHelper, []);
 
index 710857f..6631888 100644 (file)
@@ -69,6 +69,8 @@ class AbstractViewHelperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     public function argumentsCanBeRegistered()
     {
         $viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper::class, ['render'], [], '', false);
+
+        $this->mockReflectionService->method('getMethodParameters')->willReturn([]);
         $viewHelper->injectReflectionService($this->mockReflectionService);
 
         $name = 'This is a name';
@@ -104,6 +106,7 @@ class AbstractViewHelperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     public function overrideArgumentOverwritesExistingArgumentDefinition()
     {
         $viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper::class, ['render'], [], '', false);
+        $this->mockReflectionService->method('getMethodParameters')->willReturn([]);
         $viewHelper->injectReflectionService($this->mockReflectionService);
 
         $name = 'argumentName';
@@ -137,6 +140,7 @@ class AbstractViewHelperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     public function prepareArgumentsCallsInitializeArguments()
     {
         $viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper::class, ['render', 'initializeArguments'], [], '', false);
+        $this->mockReflectionService->method('getMethodParameters')->willReturn([]);
         $viewHelper->injectReflectionService($this->mockReflectionService);
 
         $viewHelper->expects($this->once())->method('initializeArguments');