[BUGFIX] Tests broken with phpunit 8.2 03/60903/3
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 8 Jun 2019 09:41:31 +0000 (11:41 +0200)
committerSusanne Moog <look@susi.dev>
Tue, 11 Jun 2019 11:32:34 +0000 (13:32 +0200)
Switching from accessibleMock to prophecy resolves
a lot of failures.
Also, using a concrete instance instead accessibleMockForAbstractClass
reduces issues.

Resolves: #88530
Releases: master, 9.5
Change-Id: I102597f74a98443fe139a76b8f168abf61349e3d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60903
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Susanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog <look@susi.dev>
13 files changed:
typo3/sysext/core/Tests/Unit/Log/Writer/AbstractWriterTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ActionControllerTest.php
typo3/sysext/fluid/Tests/Unit/Core/ViewHelper/ViewHelperResolverTest.php
typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php
typo3/sysext/form/Tests/Unit/Controller/FormFrontendControllerTest.php
typo3/sysext/form/Tests/Unit/Domain/Configuration/ConfigurationServiceTest.php
typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionValidationServiceTest.php
typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php
typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractSectionTest.php
typo3/sysext/form/Tests/Unit/Mvc/Property/PropertyMappingConfigurationTest.php
typo3/sysext/form/Tests/Unit/Mvc/Property/TypeConverter/FormDefinitionArrayConverterTest.php
typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php
typo3/sysext/seo/Tests/Unit/XmlSitemap/PagesXmlSitemapDataProviderTest.php

index 7db136d..706b678 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Log\Writer;
  * The TYPO3 project - inspiring people to share!
  */
 use TYPO3\CMS\Core\Log\Exception\InvalidLogWriterConfigurationException;
+use TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\WriterFixture;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -32,6 +33,6 @@ class AbstractWriterTest extends UnitTestCase
         $invalidConfiguration = [
             'foo' => 'bar'
         ];
-        $this->getMockForAbstractClass(\TYPO3\CMS\Core\Log\Writer\AbstractWriter::class, [$invalidConfiguration]);
+        new WriterFixture($invalidConfiguration);
     }
 }
index 1e54f3f..7cafa63 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
@@ -519,22 +520,22 @@ class ActionControllerTest extends UnitTestCase
      */
     public function rendersAndAssignsAssetsFromViewIntoPageRenderer($viewMock, $expectedHeader, $expectedFooter)
     {
-        $this->mockObjectManager = $this->createMock(ObjectManager::class);
-        $pageRendererMock = $this->getMockBuilder(PageRenderer::class)->setMethods(['addHeaderData', 'addFooterData'])->getMock();
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $pageRenderer = $this->prophesize(PageRenderer::class);
         if (!$viewMock instanceof FluidTemplateView) {
-            $this->mockObjectManager->expects($this->never())->method('get');
+            $objectManager->get(Argument::any())->shouldNotBeCalled();
         } else {
-            $this->mockObjectManager->expects($this->any())->method('get')->with(PageRenderer::class)->willReturn($pageRendererMock);
+            $objectManager->get(PageRenderer::class)->willReturn($pageRenderer->reveal());
         }
         if (!empty(trim($expectedHeader ?? ''))) {
-            $pageRendererMock->expects($this->once())->method('addHeaderData')->with($expectedHeader);
+            $pageRenderer->addHeaderData($expectedHeader)->shouldBeCalled();
         } else {
-            $pageRendererMock->expects($this->never())->method('addHeaderData');
+            $pageRenderer->addHeaderData(Argument::any())->shouldNotBeCalled();
         }
         if (!empty(trim($expectedFooter ?? ''))) {
-            $pageRendererMock->expects($this->once())->method('addFooterData')->with($expectedFooter);
+            $pageRenderer->addFooterData($expectedFooter)->shouldBeCalled();
         } else {
-            $pageRendererMock->expects($this->never())->method('addFooterData');
+            $pageRenderer->addFooterData(Argument::any())->shouldNotBeCalled();
         }
         $requestMock = $this->getMockBuilder(RequestInterface::class)->getMockForAbstractClass();
         $subject = new ActionController('');
@@ -543,7 +544,7 @@ class ActionControllerTest extends UnitTestCase
         $viewProperty->setValue($subject, $viewMock);
         $objectManagerProperty = new \ReflectionProperty($subject, 'objectManager');
         $objectManagerProperty->setAccessible(true);
-        $objectManagerProperty->setValue($subject, $this->mockObjectManager);
+        $objectManagerProperty->setValue($subject, $objectManager->reveal());
 
         $method = new \ReflectionMethod($subject, 'renderAssetsForRequest');
         $method->setAccessible(true);
index c1adb06..b5b02f3 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\Core\ViewHelper;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Fluid\Core\ViewHelper\ViewHelperResolver;
 use TYPO3\CMS\Fluid\ViewHelpers\CObjectViewHelper;
@@ -25,21 +27,17 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class ViewHelperResolverTest extends UnitTestCase
 {
+    protected $resetSingletonInstances = true;
+
     /**
      * @test
      */
     public function createViewHelperInstanceCreatesViewHelperInstanceUsingObjectManager()
     {
-        $objectManager = $this->getMockBuilder(ObjectManager::class)
-            ->setMethods(['get'])
-            ->disableOriginalConstructor()
-            ->getMock();
-        $objectManager->expects($this->once())->method('get')->with('x')->willReturn(new \stdClass());
-        $resolver = $this->getMockBuilder(ViewHelperResolver::class)
-            ->setMethods(['getObjectManager'])
-            ->getMock();
-        $resolver->expects($this->once())->method('getObjectManager')->willReturn($objectManager);
-        $this->assertInstanceOf(\stdClass::class, $resolver->createViewHelperInstanceFromClassName('x'));
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get('x')->willReturn(new \stdClass());
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
+        $this->assertInstanceOf(\stdClass::class, (new ViewHelperResolver())->createViewHelperInstanceFromClassName('x'));
     }
 
     /**
index db9b80d..06bdf45 100644 (file)
@@ -13,10 +13,11 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\Core\Widget;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Extbase\Mvc\Dispatcher;
 use TYPO3\CMS\Extbase\Mvc\Web\Request;
 use TYPO3\CMS\Extbase\Mvc\Web\Response;
-use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder;
 use TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
@@ -81,8 +82,9 @@ class WidgetRequestHandlerTest extends UnitTestCase
             ->setMethods(['build'])
             ->getMock();
         $requestBuilder->expects($this->once())->method('build')->willReturn($request);
-        $objectManager = $this->createMock(ObjectManagerInterface::class);
-        $objectManager->expects($this->once())->method('get')->willReturn($this->createMock(Response::class));
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $handler->injectObjectManager($objectManager->reveal());
+        $objectManager->get(\Prophecy\Argument::any())->willReturn($this->createMock(Response::class));
         $requestDispatcher = $this->getMockBuilder(Dispatcher::class)
             ->setMethods(['dispatch'])
             ->disableOriginalConstructor()
@@ -90,7 +92,6 @@ class WidgetRequestHandlerTest extends UnitTestCase
         $requestDispatcher->expects($this->once())->method('dispatch')->with($request);
         $this->inject($handler, 'widgetRequestBuilder', $requestBuilder);
         $this->inject($handler, 'dispatcher', $requestDispatcher);
-        $this->inject($handler, 'objectManager', $objectManager);
         $handler->handleRequest();
     }
 }
index 361aa97..bbf0ff2 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager;
+use TYPO3\CMS\Extbase\Mvc\Controller\Arguments;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Form\Controller\FormFrontendController;
 use TYPO3\CMS\Form\Domain\Configuration\ConfigurationService;
@@ -59,12 +60,9 @@ class FormFrontendControllerTest extends UnitTestCase
 
         $configurationServiceProphecy = $this->prophesize(ConfigurationService::class);
 
-        $objectManagerMock = $this->createMock(ObjectManager::class);
-        $objectManagerMock
-            ->expects($this->any())
-            ->method('get')
-            ->with(ConfigurationService::class)
-            ->willReturn($configurationServiceProphecy->reveal());
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(Arguments::class)->willReturn(new Arguments());
+        $objectManager->get(ConfigurationService::class)->willReturn($configurationServiceProphecy->reveal());
 
         $sheetIdentifier = md5(
             implode('', [
@@ -117,7 +115,7 @@ class FormFrontendControllerTest extends UnitTestCase
             ->willReturn($contentObject);
 
         $mockController->_set('configurationManager', $frontendConfigurationManager);
-        $mockController->_set('objectManager', $objectManagerMock);
+        $mockController->injectObjectManager($objectManager->reveal());
 
         $configurationServiceProphecy->getPrototypeConfiguration(Argument::cetera())->willReturn([
             'finishersDefinition' => [
@@ -196,12 +194,9 @@ class FormFrontendControllerTest extends UnitTestCase
 
         $configurationServiceProphecy = $this->prophesize(ConfigurationService::class);
 
-        $objectManagerMock = $this->createMock(ObjectManager::class);
-        $objectManagerMock
-            ->expects($this->any())
-            ->method('get')
-            ->with(ConfigurationService::class)
-            ->willReturn($configurationServiceProphecy->reveal());
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(Arguments::class)->willReturn(new Arguments());
+        $objectManager->get(ConfigurationService::class)->willReturn($configurationServiceProphecy->reveal());
 
         $sheetIdentifier = md5(
             implode('', [
@@ -254,7 +249,7 @@ class FormFrontendControllerTest extends UnitTestCase
             ->willReturn($contentObject);
 
         $mockController->_set('configurationManager', $frontendConfigurationManager);
-        $mockController->_set('objectManager', $objectManagerMock);
+        $mockController->injectObjectManager($objectManager->reveal());
 
         $configurationServiceProphecy->getPrototypeConfiguration(Argument::cetera())->willReturn([
             'finishersDefinition' => [
@@ -349,12 +344,9 @@ class FormFrontendControllerTest extends UnitTestCase
 
         $configurationServiceProphecy = $this->prophesize(ConfigurationService::class);
 
-        $objectManagerMock = $this->createMock(ObjectManager::class);
-        $objectManagerMock
-            ->expects($this->any())
-            ->method('get')
-            ->with(ConfigurationService::class)
-            ->willReturn($configurationServiceProphecy->reveal());
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(Arguments::class)->willReturn(new Arguments());
+        $objectManager->get(ConfigurationService::class)->willReturn($configurationServiceProphecy->reveal());
 
         $sheetIdentifier = md5(
             implode('', [
@@ -407,7 +399,7 @@ class FormFrontendControllerTest extends UnitTestCase
             ->willReturn($contentObject);
 
         $mockController->_set('configurationManager', $frontendConfigurationManager);
-        $mockController->_set('objectManager', $objectManagerMock);
+        $mockController->injectObjectManager($objectManager->reveal());
 
         $configurationServiceProphecy->getPrototypeConfiguration(Argument::cetera())->willReturn([
             'finishersDefinition' => [
@@ -497,14 +489,11 @@ class FormFrontendControllerTest extends UnitTestCase
 
         $typoScriptServiceProphecy = $this->prophesize(TypoScriptService::class);
 
-        $objectManagerMock = $this->createMock(ObjectManager::class);
-        $objectManagerMock
-            ->expects($this->any())
-            ->method('get')
-            ->with(TypoScriptService::class)
-            ->willReturn($typoScriptServiceProphecy->reveal());
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(Arguments::class)->willReturn(new Arguments());
+        $objectManager->get(TypoScriptService::class)->willReturn($typoScriptServiceProphecy->reveal());
 
-        $mockController->_set('objectManager', $objectManagerMock);
+        $mockController->injectObjectManager($objectManager->reveal());
 
         $typoScriptServiceProphecy
             ->resolvePossibleTypoScriptConfiguration(Argument::cetera())
@@ -569,14 +558,11 @@ class FormFrontendControllerTest extends UnitTestCase
 
         $typoScriptServiceProphecy = $this->prophesize(TypoScriptService::class);
 
-        $objectManagerMock = $this->createMock(ObjectManager::class);
-        $objectManagerMock
-            ->expects($this->any())
-            ->method('get')
-            ->with(TypoScriptService::class)
-            ->willReturn($typoScriptServiceProphecy->reveal());
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(Arguments::class)->willReturn(new Arguments());
+        $objectManager->get(TypoScriptService::class)->willReturn($typoScriptServiceProphecy->reveal());
 
-        $mockController->_set('objectManager', $objectManagerMock);
+        $mockController->injectObjectManager($objectManager->reveal());
 
         $typoScriptServiceProphecy
             ->resolvePossibleTypoScriptConfiguration(Argument::cetera())
index 6ed14a1..961a68b 100644 (file)
@@ -623,7 +623,7 @@ class ConfigurationServiceTest extends UnitTestCase
         $configurationService->expects($this->any())
             ->method('executeBuildFormDefinitionValidationConfigurationHooks')
             ->willReturnArgument(1);
-        $configurationService->expects($this->any())->method('setCacheEntry')->willReturn(null);
+        $configurationService->expects($this->any())->method('setCacheEntry');
 
         $this->assertSame(
             $expected,
index a38200d..e8ffaaf 100644 (file)
@@ -282,9 +282,10 @@ class FormDefinitionValidationServiceTest extends UnitTestCase
         $formDefinitionValidationService = $this->getAccessibleMock(FormDefinitionValidationService::class, ['getConfigurationService']);
         $formDefinitionValidationService->expects($this->any())->method('getConfigurationService')->willReturn($configurationService);
         GeneralUtility::setSingletonInstance(FormDefinitionValidationService::class, $formDefinitionValidationService);
-        $objectManager = $this->createMock(ObjectManager::class);
-        $objectManager->expects($this->once())->method('get')->with(ConfigurationService::class)->willReturn($configurationService);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager);
+
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(ConfigurationService::class)->willReturn($configurationService);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
 
         $returnedExceptionCode = -1;
         try {
@@ -338,9 +339,9 @@ class FormDefinitionValidationServiceTest extends UnitTestCase
         $formDefinitionValidationService = $this->getAccessibleMock(FormDefinitionValidationService::class, ['getConfigurationService']);
         $formDefinitionValidationService->expects($this->any())->method('getConfigurationService')->willReturn($configurationService);
         GeneralUtility::setSingletonInstance(FormDefinitionValidationService::class, $formDefinitionValidationService);
-        $objectManager = $this->createMock(ObjectManager::class);
-        $objectManager->expects($this->once())->method('get')->with(ConfigurationService::class)->willReturn($configurationService);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager);
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(ConfigurationService::class)->willReturn($configurationService);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
 
         $returnedExceptionCode = -1;
         try {
index 54d961f..c2c4754 100644 (file)
@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException;
 use TYPO3\CMS\Form\Domain\Model\FormDefinition;
 use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractFormElement;
+use TYPO3\CMS\Form\Domain\Model\FormElements\GenericFormElement;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -139,15 +140,8 @@ class AbstractFormElementTest extends UnitTestCase
         $this->expectException(IdentifierNotValidException::class);
         $this->expectExceptionCode(1477082502);
 
-        $this->getAccessibleMockForAbstractClass(
-            AbstractFormElement::class,
-            ['', 'a_type'],
-            '',
-            true,
-            true,
-            true,
-            []
-        );
+        // GenericFormElement inherits from AbstractFormElement and serves as concrete implementation
+        new GenericFormElement('', 'a_type');
     }
 
     /**
index 51848c1..5f0d691 100644 (file)
@@ -23,6 +23,7 @@ use TYPO3\CMS\Form\Domain\Exception\TypeDefinitionNotValidException;
 use TYPO3\CMS\Form\Domain\Model\FormDefinition;
 use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractFormElement;
 use TYPO3\CMS\Form\Domain\Model\FormElements\AbstractSection;
+use TYPO3\CMS\Form\Domain\Model\FormElements\Section;
 use TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -31,6 +32,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class AbstractSectionTest extends UnitTestCase
 {
+    protected $resetSingletonInstances = true;
+
     /**
      * @test
      */
@@ -39,7 +42,8 @@ class AbstractSectionTest extends UnitTestCase
         $this->expectException(IdentifierNotValidException::class);
         $this->expectExceptionCode(1477082501);
 
-        $this->getAccessibleMockForAbstractClass(AbstractSection::class, ['', 'foobar']);
+        // Section inherits from AbstractSection and serves as concrete implementation
+        new Section('', 'foobar');
     }
 
     /**
@@ -47,8 +51,8 @@ class AbstractSectionTest extends UnitTestCase
      */
     public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString()
     {
-        $mock = $this->getAccessibleMockForAbstractClass(AbstractSection::class, ['foobar', 'foobar']);
-        $this->assertInstanceOf(AbstractSection::class, $mock);
+        $section = new Section('foobar', 'foobar');
+        $this->assertInstanceOf(AbstractSection::class, $section);
     }
 
     /**
@@ -131,19 +135,11 @@ class AbstractSectionTest extends UnitTestCase
             ->method('getRootForm')
             ->willReturn($rootForm);
 
-        $objectManager = $this->getMockBuilder(ObjectManager::class)
-            ->setMethods(['get'])
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $objectManager
-            ->expects($this->any())
-            ->method('get')
-            ->willReturn(new UnknownFormElement('foo', 'bar'));
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(UnknownFormElement::class, 'foo', 'bar')->willReturn(new UnknownFormElement('foo', 'bar'));
 
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
         $result = $mockAbstractSection->createElement('foo', 'bar');
-        GeneralUtility::removeSingletonInstance(ObjectManager::class, $objectManager);
 
         $this->assertInstanceOf(UnknownFormElement::class, $result);
         $this->assertSame('foo', $result->getIdentifier());
@@ -237,19 +233,13 @@ class AbstractSectionTest extends UnitTestCase
             ->method('getRootForm')
             ->willReturn($rootForm);
 
-        $objectManager = $this->createMock(ObjectManager::class);
-        $objectManager
-            ->method('get')
-            ->with(self::class)
-            ->willReturn($this);
-
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager);
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(self::class, 'id', 'foobar')->willReturn($this);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
 
         $this->expectException(TypeDefinitionNotValidException::class);
         $this->expectExceptionCode(1327318156);
         $mockAbstractSection->createElement('id', 'foobar');
-
-        GeneralUtility::removeSingletonInstance(ObjectManager::class, $objectManager);
     }
 
     /**
@@ -317,16 +307,11 @@ class AbstractSectionTest extends UnitTestCase
             ->method('getRootForm')
             ->willReturn($rootForm);
 
-        $objectManager = $this->createMock(ObjectManager::class);
-        $objectManager
-            ->method('get')
-            ->with(get_class($implementationMock))
-            ->willReturn($implementationMock);
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(get_class($implementationMock), 'id', 'foobar')->willReturn($implementationMock);
 
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
 
         $mockAbstractSection->createElement('id', 'foobar');
-
-        GeneralUtility::removeSingletonInstance(ObjectManager::class, $objectManager);
     }
 }
index 99424d4..52f6151 100644 (file)
@@ -120,21 +120,10 @@ class PropertyMappingConfigurationTest extends UnitTestCase
         $resourceFactory = $this->createMock(ResourceFactory::class);
 
         // Object Manager (in order to return mocked Resource Factory)
-        /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $objectManager */
-        $objectManager = $this->getMockBuilder(ObjectManager::class)
-            ->setMethods(['get'])
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $objectManager
-            ->expects($this->any())
-            ->method('get')
-            ->willReturnMap([
-                [MimeTypeValidator::class, $mimeTypeValidator],
-                [ResourceFactory::class, $resourceFactory]
-            ]);
-
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager);
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(MimeTypeValidator::class)->willReturn($mimeTypeValidator);
+        $objectManager->get(ResourceFactory::class)->willReturn($resourceFactory);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
 
         // No validators
         $this->processingRule
@@ -172,19 +161,9 @@ class PropertyMappingConfigurationTest extends UnitTestCase
             ->getMock();
 
         // Object Manager to return the MimeTypeValidator
-        /** @var \PHPUnit_Framework_MockObject_MockObject|ObjectManager $objectManager */
-        $objectManager = $this->getMockBuilder(ObjectManager::class)
-            ->setMethods(['get'])
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $objectManager
-            ->expects($this->any())
-            ->method('get')
-            ->with(MimeTypeValidator::class, $mimeTypes)
-            ->willReturn($mimeTypeValidator);
-
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager);
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(MimeTypeValidator::class, $mimeTypes)->willReturn($mimeTypeValidator);
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
 
         // Don't add any validators for now
         $this->processingRule
index a22b5f2..617694b 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Form\Tests\Unit\Mvc\Property\TypeConverter;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Form\Domain\Configuration\Exception\PropertyException;
 use TYPO3\CMS\Form\Domain\Configuration\FormDefinitionValidationService;
@@ -71,10 +72,9 @@ class FormDefinitionArrayConverterTest extends UnitTestCase
         ];
 
         $typeConverter = $this->getAccessibleMock(FormDefinitionArrayConverter::class, ['getFormDefinitionValidationService', 'retrieveSessionToken'], [], '', false);
-        $formDefinitionValidationService = $this->getAccessibleMock(FormDefinitionValidationService::class, ['validateFormDefinitionProperties'], [], '', false);
-        $formDefinitionValidationService->expects($this->any())->method(
-            'validateFormDefinitionProperties'
-        )->willReturn(null);
+        $formDefinitionValidationService = $this->prophesize(FormDefinitionValidationService::class);
+        $formDefinitionValidationService->validateFormDefinitionProperties(Argument::cetera())->shouldBeCalled();
+        $formDefinitionValidationService->isPropertyValueEqualToHistoricalValue(Argument::cetera())->willReturn(true);
 
         $typeConverter->expects($this->any())->method(
             'retrieveSessionToken'
@@ -82,7 +82,7 @@ class FormDefinitionArrayConverterTest extends UnitTestCase
 
         $typeConverter->expects($this->any())->method(
             'getFormDefinitionValidationService'
-        )->willReturn($formDefinitionValidationService);
+        )->willReturn($formDefinitionValidationService->reveal());
 
         $input = json_encode($data);
         $expected = [
index 2275066..8ce5b25 100644 (file)
@@ -375,8 +375,8 @@ class FrontendUserAuthenticationTest extends UnitTestCase
             'uid' => 1,
             'username' => 'existingUserName'
         ]);
-        // Auth services can return true or 200
-        $authServiceMock->method('authUser')->willReturn(true);
+        // Auth services can return status codes: 0 (failed/abort), 100 (not responsible, continue), 200 (ok)
+        $authServiceMock->method('authUser')->willReturn(200);
         // We need to wrap the array to something thats is \Traversable, in PHP 7.1 we can use traversable pseudo type instead
         $subject->method('getAuthServices')->willReturn(new \ArrayIterator([$authServiceMock]));
 
index a2631be..371447c 100644 (file)
@@ -23,6 +23,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class PagesXmlSitemapDataProviderTest extends UnitTestCase
 {
+    protected $resetSingletonInstances = true;
+
     /**
      * @var array
      */
@@ -66,7 +68,6 @@ class PagesXmlSitemapDataProviderTest extends UnitTestCase
             '',
             true
         );
-        $subject->expects($this->any())->method('generateItems')->willReturn(null);
         $this->assertEquals($key, $subject->getKey());
     }