[TASK] Avoid buildAccessibleProxy in tests 89/62789/3
authorBenni Mack <benni@typo3.org>
Mon, 30 Dec 2019 10:48:13 +0000 (11:48 +0100)
committerBenni Mack <benni@typo3.org>
Mon, 30 Dec 2019 11:20:08 +0000 (12:20 +0100)
Tests should use getAccessibleMock() in all cases so
our testing API is used consistently everywhere.

The tests also show that some changes could be
made without having accessible proxies nowadays.

Resolves: #90037
Releases: master
Change-Id: I4a3f2948d9f645d736949fed4161cd91b1f3df0c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62789
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Tests/Functional/Controller/PageLayoutControllerTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/ApcuBackendTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/WincacheBackendTest.php
typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/MvcPropertyMappingConfigurationServiceTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/PersistenceManagerTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/ConjunctionValidatorTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Link/EmailViewHelperTest.php
typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php

index 3d16d67..3cec1f3 100644 (file)
@@ -18,7 +18,6 @@ use TYPO3\CMS\Backend\Controller\PageLayoutController;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
@@ -62,8 +61,7 @@ class PageLayoutControllerTest extends FunctionalTestCase
     {
         parent::setUp();
 
-        $className = $this->buildAccessibleProxy(PageLayoutController::class);
-        $this->subject = GeneralUtility::makeInstance($className);
+        $this->subject = $this->getAccessibleMock(PageLayoutController::class, ['dummy']);
         $this->backendUser = $this->setUpBackendUserFromFixture(1);
 
         $this->withDatabaseSnapshot(function () {
index d38342b..322c822 100644 (file)
@@ -279,8 +279,7 @@ class ApcuBackendTest extends UnitTestCase
         /** @var \PHPUnit\Framework\MockObject\MockObject|FrontendInterface $cache */
         $cache = $this->createMock(FrontendInterface::class);
         if ($accessible) {
-            $accessibleClassName = $this->buildAccessibleProxy(ApcuBackend::class);
-            $backend = new $accessibleClassName('Testing');
+            $backend = $this->getAccessibleMock(ApcuBackend::class, ['dummy'], ['Testing']);
         } else {
             $backend = new ApcuBackend('Testing');
         }
index 30ba06d..de21aa4 100644 (file)
@@ -264,8 +264,7 @@ class WincacheBackendTest extends UnitTestCase
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface $cache */
         $cache = $this->createMock(\TYPO3\CMS\Core\Cache\Frontend\FrontendInterface::class);
         if ($accessible) {
-            $accessibleClassName = $this->buildAccessibleProxy(WincacheBackend::class);
-            $backend = new $accessibleClassName('Testing');
+            $backend = $this->getAccessibleMock(WincacheBackend::class, ['dummy'], ['Testing']);
         } else {
             $backend = new WincacheBackend('Testing');
         }
index 3b053ec..fb433bc 100644 (file)
@@ -42,8 +42,7 @@ class TypoScriptParserTest extends UnitTestCase
     protected function setUp(): void
     {
         parent::setUp();
-        $accessibleClassName = $this->buildAccessibleProxy(TypoScriptParser::class);
-        $this->typoScriptParser = new $accessibleClassName();
+        $this->typoScriptParser = $this->getAccessibleMock(TypoScriptParser::class, ['dummy']);
     }
 
     /**
index 6d91781..775577a 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService;
+use TYPO3\CMS\Extbase\Security\Cryptography\HashService;
 use TYPO3\CMS\Extbase\Security\Exception\InvalidArgumentForHashGenerationException;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -120,7 +122,7 @@ class MvcPropertyMappingConfigurationServiceTest extends UnitTestCase
      */
     public function generateTrustedPropertiesTokenGeneratesTheCorrectHashesInNormalOperation($input, $expected)
     {
-        $requestHashService = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class)
+        $requestHashService = $this->getMockBuilder(MvcPropertyMappingConfigurationService::class)
             ->setMethods(['serializeAndHashFormFieldArray'])
             ->getMock();
         $requestHashService->expects(self::once())->method('serializeAndHashFormFieldArray')->with($expected);
@@ -137,7 +139,7 @@ class MvcPropertyMappingConfigurationServiceTest extends UnitTestCase
     {
         $this->expectException(InvalidArgumentForHashGenerationException::class);
         $this->expectExceptionCode($expectExceptionCode);
-        $requestHashService = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class)
+        $requestHashService = $this->getMockBuilder(MvcPropertyMappingConfigurationService::class)
             ->setMethods(['serializeAndHashFormFieldArray'])
             ->getMock();
         $requestHashService->generateTrustedPropertiesToken($input);
@@ -156,15 +158,13 @@ class MvcPropertyMappingConfigurationServiceTest extends UnitTestCase
         ];
         $mockHash = '12345';
 
-        $hashService = $this->getMockBuilder($this->buildAccessibleProxy(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class))
+        $hashService = $this->getMockBuilder(HashService::class)
             ->setMethods(['appendHmac'])
             ->getMock();
         $hashService->expects(self::once())->method('appendHmac')->with(json_encode($formFieldArray))->willReturn(json_encode($formFieldArray) . $mockHash);
 
-        $requestHashService = $this->getMockBuilder($this->buildAccessibleProxy(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class))
-            ->setMethods(['dummy'])
-            ->getMock();
-        $requestHashService->_set('hashService', $hashService);
+        $requestHashService = $this->getAccessibleMock(MvcPropertyMappingConfigurationService::class, ['dummy']);
+        $requestHashService->injectHashService($hashService);
 
         $expected = json_encode($formFieldArray) . $mockHash;
         $actual = $requestHashService->_call('serializeAndHashFormFieldArray', $formFieldArray);
@@ -180,7 +180,7 @@ class MvcPropertyMappingConfigurationServiceTest extends UnitTestCase
         $request->expects(self::any())->method('getInternalArgument')->with('__trustedProperties')->willReturn(null);
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
 
-        $requestHashService = new \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService;
+        $requestHashService = new MvcPropertyMappingConfigurationService;
         $requestHashService->initializePropertyMappingConfigurationFromRequest($request, $arguments);
     }
 
@@ -304,7 +304,7 @@ class MvcPropertyMappingConfigurationServiceTest extends UnitTestCase
             ->getMock();
         $mockHashService->expects(self::once())->method('validateAndStripHmac')->with('fooTrustedProperties')->willReturn(json_encode($trustedProperties));
 
-        $requestHashService = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService::class, ['dummy']);
+        $requestHashService = $this->getAccessibleMock(MvcPropertyMappingConfigurationService::class, ['dummy']);
         $requestHashService->_set('hashService', $mockHashService);
 
         $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
index 0b83165..5bfa0d7 100644 (file)
@@ -349,7 +349,7 @@ class PersistenceManagerTest extends UnitTestCase
         $repository = $this->getAccessibleMock($repositorClassNameWithNamespace, ['dummy'], [$this->mockObjectManager]);
         $repository->_set('objectType', get_class($entity1));
         /** @var \TYPO3\CMS\Extbase\Persistence\Generic\Backend|MockObject $mockBackend */
-        $mockBackend = $this->getMockBuilder($this->buildAccessibleProxy(Backend::class))
+        $mockBackend = $this->getMockBuilder(Backend::class)
             ->setMethods(['commit', 'setChangedEntities'])
             ->disableOriginalConstructor()
             ->getMock();
@@ -439,7 +439,7 @@ class PersistenceManagerTest extends UnitTestCase
         $entity1 = new $classNameWithNamespace();
         $aggregateRootObjects->attach($entity1);
         /** @var \TYPO3\CMS\Extbase\Persistence\Generic\Backend|MockObject $mockBackend */
-        $mockBackend = $this->getMockBuilder($this->buildAccessibleProxy(Backend::class))
+        $mockBackend = $this->getMockBuilder(Backend::class)
             ->setMethods(['commit', 'setAggregateRootObjects', 'setDeletedEntities'])
             ->disableOriginalConstructor()
             ->getMock();
index 46147b6..40ba8e4 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator;
  */
 
 use TYPO3\CMS\Extbase\Validation\Exception\NoSuchValidatorException;
+use TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -27,11 +28,10 @@ class ConjunctionValidatorTest extends UnitTestCase
      */
     public function addingValidatorsToAJunctionValidatorWorks()
     {
-        $proxyClassName = $this->buildAccessibleProxy(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class);
-        $conjunctionValidator = new $proxyClassName([]);
+        $conjunctionValidator = new ConjunctionValidator();
         $mockValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
         $conjunctionValidator->addValidator($mockValidator);
-        self::assertTrue($conjunctionValidator->_get('validators')->contains($mockValidator));
+        self::assertTrue($conjunctionValidator->getValidators()->contains($mockValidator));
     }
 
     /**
@@ -39,7 +39,7 @@ class ConjunctionValidatorTest extends UnitTestCase
      */
     public function allValidatorsInTheConjunctionAreCalledEvenIfOneReturnsError()
     {
-        $validatorConjunction = new \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator([]);
+        $validatorConjunction = new ConjunctionValidator();
         $validatorObject = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class)
             ->setMethods(['validate', 'getOptions'])
             ->getMock();
@@ -65,7 +65,7 @@ class ConjunctionValidatorTest extends UnitTestCase
      */
     public function validatorConjunctionReturnsNoErrorsIfAllJunctionedValidatorsReturnNoErrors()
     {
-        $validatorConjunction = new \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator([]);
+        $validatorConjunction = new ConjunctionValidator([]);
         $validatorObject = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class)
             ->setMethods(['validate', 'getOptions'])
             ->getMock();
@@ -84,7 +84,7 @@ class ConjunctionValidatorTest extends UnitTestCase
      */
     public function validatorConjunctionReturnsErrorsIfOneValidatorReturnsErrors()
     {
-        $validatorConjunction = new \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator([]);
+        $validatorConjunction = new ConjunctionValidator([]);
         $validatorObject = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class)
             ->setMethods(['validate', 'getOptions'])
             ->getMock();
@@ -100,8 +100,7 @@ class ConjunctionValidatorTest extends UnitTestCase
      */
     public function removingAValidatorOfTheValidatorConjunctionWorks()
     {
-        /** @var \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $validatorConjunction = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator::class, ['dummy'], [[]], '', true);
+        $validatorConjunction = new ConjunctionValidator();
         $validator1 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class)
             ->setMethods(['validate', 'getOptions'])
             ->getMock();
@@ -111,8 +110,8 @@ class ConjunctionValidatorTest extends UnitTestCase
         $validatorConjunction->addValidator($validator1);
         $validatorConjunction->addValidator($validator2);
         $validatorConjunction->removeValidator($validator1);
-        self::assertFalse($validatorConjunction->_get('validators')->contains($validator1));
-        self::assertTrue($validatorConjunction->_get('validators')->contains($validator2));
+        self::assertFalse($validatorConjunction->getValidators()->contains($validator1));
+        self::assertTrue($validatorConjunction->getValidators()->contains($validator2));
     }
 
     /**
@@ -122,7 +121,7 @@ class ConjunctionValidatorTest extends UnitTestCase
     {
         $this->expectException(NoSuchValidatorException::class);
         $this->expectExceptionCode(1207020177);
-        $validatorConjunction = new \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator([]);
+        $validatorConjunction = new ConjunctionValidator();
         $validator = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class)
             ->setMethods(['validate', 'getOptions'])
             ->getMock();
@@ -134,7 +133,7 @@ class ConjunctionValidatorTest extends UnitTestCase
      */
     public function countReturnesTheNumberOfValidatorsContainedInTheConjunction()
     {
-        $validatorConjunction = new \TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator([]);
+        $validatorConjunction = new ConjunctionValidator();
         $validator1 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class)
             ->setMethods(['validate', 'getOptions'])
             ->getMock();
index 13a77a4..9496239 100644 (file)
@@ -15,64 +15,38 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
-use TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfigurationService;
 use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
 use TYPO3\CMS\Extbase\Security\Cryptography\HashService;
 use TYPO3\CMS\Extbase\Service\ExtensionService;
 use TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper;
 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
-use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface;
 
 /**
  * Test for the Form view helper
  */
 class FormViewHelperTest extends ViewHelperBaseTestcase
 {
-    /**
-     * @var ExtensionService
-     */
-    protected $mockExtensionService;
-
-    /**
-     * @var ConfigurationManagerInterface
-     */
-    protected $mockConfigurationManager;
-
-    /**
-     * @var MvcPropertyMappingConfigurationService
-     */
-    protected $mvcPropertyMapperConfigurationService;
-
-    /**
-     * @var UriBuilder
-     */
-    protected $uriBuilder;
-
     protected function setUp(): void
     {
         parent::setUp();
-        $this->uriBuilder = $this->createMock(UriBuilder::class);
-        $this->uriBuilder->expects(self::any())->method('reset')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setArguments')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setSection')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setFormat')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setCreateAbsoluteUri')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setAddQueryString')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setArgumentsToBeExcludedFromQueryString')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setLinkAccessRestrictedPages')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setTargetPageUid')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setTargetPageType')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setNoCache')->willReturn($this->uriBuilder);
-        $this->uriBuilder->expects(self::any())->method('setAddQueryStringMethod')->willReturn($this->uriBuilder);
-        $this->controllerContext->expects(self::any())->method('getUriBuilder')->willReturn($this->uriBuilder);
+        $uriBuilderMock = $this->createMock(UriBuilder::class);
+        $uriBuilderMock->expects(self::any())->method('reset')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setArguments')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setSection')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setFormat')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setCreateAbsoluteUri')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setAddQueryString')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setArgumentsToBeExcludedFromQueryString')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setLinkAccessRestrictedPages')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setTargetPageUid')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setTargetPageType')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setNoCache')->willReturn($uriBuilderMock);
+        $uriBuilderMock->expects(self::any())->method('setAddQueryStringMethod')->willReturn($uriBuilderMock);
+        $this->controllerContext->expects(self::any())->method('getUriBuilder')->willReturn($uriBuilderMock);
         $this->renderingContext->setControllerContext($this->controllerContext);
 
-        $this->mockExtensionService = $this->createMock(ExtensionService::class);
-        $this->mockConfigurationManager = $this->createMock(ConfigurationManagerInterface::class);
         $this->tagBuilder = $this->createMock(TagBuilder::class);
-        $this->mvcPropertyMapperConfigurationService = $this->getAccessibleMock(MvcPropertyMappingConfigurationService::class, ['dummy']);
     }
 
     /**
@@ -104,28 +78,12 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
             ->setMethods(['addAttribute'])
             ->getMock();
         $tagBuilder->expects(self::once())->method('addAttribute')->with('action', 'foobar');
-        $viewHelper->_set('tag', $tagBuilder);
+        $viewHelper->setTagBuilder($tagBuilder);
         $viewHelper->setArguments(['actionUri' => 'foobar']);
         $viewHelper->_call('setFormActionUri');
     }
 
     /**
-     * @param ViewHelperInterface $viewHelper
-     */
-    protected function injectDependenciesIntoViewHelper(ViewHelperInterface $viewHelper)
-    {
-        $viewHelper->_set('configurationManager', $this->mockConfigurationManager);
-        parent::injectDependenciesIntoViewHelper($viewHelper);
-        $hashService = $this->getMockBuilder(HashService::class)
-            ->setMethods(['appendHmac'])
-            ->getMock();
-        $hashService->expects(self::any())->method('appendHmac')->willReturn('');
-        $this->mvcPropertyMapperConfigurationService->injectHashService($hashService);
-        $viewHelper->_set('mvcPropertyMapperConfigurationService', $this->mvcPropertyMapperConfigurationService);
-        $viewHelper->_set('hashService', $hashService);
-    }
-
-    /**
      * @test
      */
     public function renderAddsObjectToViewHelperVariableContainer()
@@ -138,7 +96,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $this->viewHelperVariableContainer->add(FormViewHelper::class, 'additionalIdentityProperties', []);
         $this->viewHelperVariableContainer->remove(FormViewHelper::class, 'formObject');
         $this->viewHelperVariableContainer->remove(FormViewHelper::class, 'additionalIdentityProperties');
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -153,7 +111,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(['name' => $objectName]);
         $this->viewHelperVariableContainer->add(FormViewHelper::class, 'formObjectName', $objectName);
         $this->viewHelperVariableContainer->remove(FormViewHelper::class, 'formObjectName');
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -168,7 +126,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(['name' => 'formName', 'objectName' => $objectName]);
         $this->viewHelperVariableContainer->add(FormViewHelper::class, 'formObjectName', $objectName);
         $this->viewHelperVariableContainer->remove(FormViewHelper::class, 'formObjectName');
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -180,7 +138,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper = $this->getAccessibleMock(FormViewHelper::class, ['renderChildren', 'renderRequestHashField', 'renderHiddenReferrerFields', 'renderTrustedPropertiesField'], [], '', false);
         $viewHelper->expects(self::once())->method('renderHiddenReferrerFields');
         $this->injectDependenciesIntoViewHelper($viewHelper);
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -195,7 +153,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(['object' => $object]);
         $viewHelper->expects(self::atLeastOnce())->method('getFormObjectName')->willReturn('MyName');
         $viewHelper->expects(self::once())->method('renderHiddenIdentityField')->with($object, 'MyName');
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -207,7 +165,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper = $this->getAccessibleMock(FormViewHelper::class, ['renderChildren', 'renderRequestHashField', 'renderHiddenReferrerFields', 'renderAdditionalIdentityFields', 'renderTrustedPropertiesField'], [], '', false);
         $viewHelper->expects(self::once())->method('renderAdditionalIdentityFields');
         $this->injectDependenciesIntoViewHelper($viewHelper);
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -216,9 +174,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
      */
     public function renderWrapsHiddenFieldsWithDivForXhtmlCompatibilityWithRewrittenPropertyMapper()
     {
-        $viewHelper = $this->getAccessibleMock($this->buildAccessibleProxy(FormViewHelper::class), ['renderChildren', 'renderHiddenIdentityField', 'renderAdditionalIdentityFields', 'renderHiddenReferrerFields', 'renderHiddenSecuredReferrerField', 'renderTrustedPropertiesField'], [], '', false);
-        $this->mvcPropertyMapperConfigurationService->injectHashService(new HashService());
-        $viewHelper->_set('mvcPropertyMapperConfigurationService', $this->mvcPropertyMapperConfigurationService);
+        $viewHelper = $this->getAccessibleMock(FormViewHelper::class, ['renderChildren', 'renderHiddenIdentityField', 'renderAdditionalIdentityFields', 'renderHiddenReferrerFields', 'renderHiddenSecuredReferrerField', 'renderTrustedPropertiesField'], [], '', false);
         parent::injectDependenciesIntoViewHelper($viewHelper);
         $viewHelper->expects(self::once())->method('renderHiddenIdentityField')->willReturn('hiddenIdentityField');
         $viewHelper->expects(self::once())->method('renderAdditionalIdentityFields')->willReturn('additionalIdentityFields');
@@ -226,7 +182,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->expects(self::once())->method('renderChildren')->willReturn('formContent');
         $expectedResult =  \chr(10) . '<div>hiddenIdentityFieldadditionalIdentityFieldshiddenReferrerFields' . \chr(10) . '</div>' . \chr(10) . 'formContent';
         $this->tagBuilder->expects(self::once())->method('setContent')->with($expectedResult);
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -235,12 +191,15 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
      */
     public function renderWrapsHiddenFieldsWithDivAndAnAdditionalClassForXhtmlCompatibilityWithRewrittenPropertyMapper()
     {
-        $viewHelper = $this->getMockBuilder($this->buildAccessibleProxy(FormViewHelper::class))
-            ->setMethods(['renderChildren', 'renderHiddenIdentityField', 'renderAdditionalIdentityFields', 'renderHiddenReferrerFields', 'renderHiddenSecuredReferrerField', 'renderTrustedPropertiesField'])
-            ->disableOriginalConstructor()
-            ->getMock();
-        $this->mvcPropertyMapperConfigurationService->injectHashService(new HashService());
-        $viewHelper->_set('mvcPropertyMapperConfigurationService', $this->mvcPropertyMapperConfigurationService);
+        $viewHelper = $this->getAccessibleMock(
+            FormViewHelper::class,
+            [
+                'renderChildren', 'renderHiddenIdentityField', 'renderAdditionalIdentityFields', 'renderHiddenReferrerFields', 'renderHiddenSecuredReferrerField', 'renderTrustedPropertiesField'
+            ],
+            [],
+            '',
+            false
+        );
         parent::injectDependenciesIntoViewHelper($viewHelper);
         $viewHelper->expects(self::once())->method('renderHiddenIdentityField')->willReturn('hiddenIdentityField');
         $viewHelper->expects(self::once())->method('renderAdditionalIdentityFields')->willReturn('additionalIdentityFields');
@@ -249,7 +208,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $expectedResult =  \chr(10) . '<div class="hidden">hiddenIdentityFieldadditionalIdentityFieldshiddenReferrerFields' . \chr(10) . '</div>' . \chr(10) . 'formContent';
         $this->tagBuilder->expects(self::once())->method('setContent')->with($expectedResult);
         $viewHelper->setArguments(['hiddenFieldClassName' => 'hidden']);
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -268,7 +227,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $this->injectDependenciesIntoViewHelper($viewHelper);
         $expected =  \chr(10) . '<input type="hidden" name="object1[object2][__identity]" value="42" />' . \chr(10) . '<input type="hidden" name="object1[object2][subobject][__identity]" value="21" />';
         $actual = $viewHelper->_call('renderAdditionalIdentityFields');
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         self::assertEquals($expected, $actual);
     }
 
@@ -279,6 +238,11 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
     {
         $viewHelper = $this->getAccessibleMock(FormViewHelper::class, ['dummy'], [], '', false);
         $this->injectDependenciesIntoViewHelper($viewHelper);
+        $hashService = $this->getMockBuilder(HashService::class)
+            ->setMethods(['appendHmac'])
+            ->getMock();
+        $hashService->expects(self::any())->method('appendHmac')->willReturn('');
+        $viewHelper->injectHashService($hashService);
         $this->request->getControllerExtensionName()->willReturn('extensionName');
         $this->request->getControllerName()->willReturn('controllerName');
         $this->request->getControllerActionName()->willReturn('controllerActionName');
@@ -288,7 +252,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
             . \chr(10) . '<input type="hidden" name="__referrer[@controller]" value="controllerName" />'
             . \chr(10) . '<input type="hidden" name="__referrer[@action]" value="controllerActionName" />'
             . \chr(10) . '<input type="hidden" name="__referrer[@request]" value="" />' . \chr(10);
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         self::assertEquals($expectedResult, $hiddenFields);
     }
 
@@ -303,7 +267,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->setArguments(['fieldNamePrefix' => $prefix]);
         $this->viewHelperVariableContainer->add(FormViewHelper::class, 'fieldNamePrefix', $prefix);
         $this->viewHelperVariableContainer->remove(FormViewHelper::class, 'fieldNamePrefix');
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
@@ -314,13 +278,14 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
     {
         $expectedPrefix = 'tx_someextension_someplugin';
         $viewHelper = $this->getAccessibleMock(FormViewHelper::class, ['renderChildren', 'renderHiddenIdentityField', 'renderHiddenReferrerFields', 'renderRequestHashField', 'addFormFieldNamesToViewHelperVariableContainer', 'removeFormFieldNamesFromViewHelperVariableContainer', 'renderTrustedPropertiesField'], [], '', false);
-        $this->mockExtensionService->expects(self::once())->method('getPluginNamespace')->with('SomeExtension', 'SomePlugin')->willReturn('tx_someextension_someplugin');
-        $viewHelper->_set('extensionService', $this->mockExtensionService);
+        $mockExtensionService = $this->createMock(ExtensionService::class);
+        $mockExtensionService->expects(self::once())->method('getPluginNamespace')->with('SomeExtension', 'SomePlugin')->willReturn('tx_someextension_someplugin');
+        $viewHelper->injectExtensionService($mockExtensionService);
         $this->injectDependenciesIntoViewHelper($viewHelper);
         $viewHelper->setArguments(['extensionName' => 'SomeExtension', 'pluginName' => 'SomePlugin']);
         $this->viewHelperVariableContainer->add(FormViewHelper::class, 'fieldNamePrefix', $expectedPrefix);
         $this->viewHelperVariableContainer->remove(FormViewHelper::class, 'fieldNamePrefix');
-        $viewHelper->_set('tag', $this->tagBuilder);
+        $viewHelper->setTagBuilder($this->tagBuilder);
         $viewHelper->render();
     }
 
index 0fdb64e..defe43d 100644 (file)
@@ -26,7 +26,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
 class EmailViewHelperTest extends ViewHelperBaseTestcase
 {
     /**
-     * @var \TYPO3\CMS\Fluid\ViewHelpers\Link\EmailViewHelper
+     * @var EmailViewHelper
      */
     protected $viewHelper;
 
@@ -40,9 +40,7 @@ class EmailViewHelperTest extends ViewHelperBaseTestcase
         parent::setUp();
         $GLOBALS['TSFE'] = new \stdClass();
         $GLOBALS['TSFE']->cObj = $this->createMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
-        $this->viewHelper = $this->getMockBuilder($this->buildAccessibleProxy(\TYPO3\CMS\Fluid\ViewHelpers\Link\EmailViewHelper::class))
-            ->setMethods(['renderChildren'])
-            ->getMock();
+        $this->viewHelper = $this->getAccessibleMock(EmailViewHelper::class, ['renderChildren']);
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
     }
 
index 23fd481..08ecccf 100644 (file)
@@ -353,14 +353,15 @@ class FrontendUserAuthenticationTest extends UnitTestCase
         GeneralUtility::addInstance(Random::class, $randomProphecy->reveal());
 
         // Mock the login data and auth services here since fully prophesize this is a lot of hassle
-        $subject = $this->getMockBuilder($this->buildAccessibleProxy(FrontendUserAuthentication::class))
-            ->setMethods([
+        $subject = $this->getAccessibleMock(
+            FrontendUserAuthentication::class,
+            [
                 'getLoginFormData',
                 'getAuthServices',
                 'createUserSession',
                 'getCookie',
-            ])
-            ->getMock();
+            ]
+        );
         $subject->setLogger(new NullLogger());
         $subject->gc_probability = -1;
 
@@ -388,7 +389,7 @@ class FrontendUserAuthenticationTest extends UnitTestCase
         $subject->method('getCookie')->willReturn(null);
 
         $subject->start();
-        self::assertFalse($subject->_get('loginFailure'));
+        self::assertFalse($subject->loginFailure);
         self::assertEquals('existingUserName', $subject->user['username']);
     }
 
index 8b47d7e..03942bf 100644 (file)
@@ -48,8 +48,7 @@ class AbstractMenuContentObjectTest extends UnitTestCase
     {
         parent::setUp();
         $GLOBALS['TYPO3_REQUEST'] = new ServerRequest('https://www.example.com', 'GET');
-        $proxyClassName = $this->buildAccessibleProxy(AbstractMenuContentObject::class);
-        $this->subject = $this->getMockForAbstractClass($proxyClassName);
+        $this->subject = $this->getAccessibleMockForAbstractClass(AbstractMenuContentObject::class);
         $site = new Site('test', 1, [
             'base' => 'https://www.example.com',
             'languages' => [
@@ -360,8 +359,7 @@ class AbstractMenuContentObjectTest extends UnitTestCase
         $runtimeCacheMock->expects(self::once())->method('get')->with(self::anything())->willReturn(false);
         $runtimeCacheMock->expects(self::once())->method('set')->with(self::anything(), ['result' => $expectedResult]);
 
-        $proxyClassName = $this->buildAccessibleProxy(AbstractMenuContentObject::class);
-        $this->subject = $this->getMockForAbstractClass($proxyClassName, [], '', true, true, true, ['getRuntimeCache']);
+        $this->subject = $this->getAccessibleMockForAbstractClass(AbstractMenuContentObject::class, [], '', true, true, true, ['getRuntimeCache']);
         $this->subject->expects(self::once())->method('getRuntimeCache')->willReturn($runtimeCacheMock);
         $this->prepareSectionIndexTest();