[TASK] Speed up tests 47/62547/16
authorBenni Mack <benni@typo3.org>
Thu, 5 Dec 2019 18:57:55 +0000 (19:57 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 18 Dec 2019 11:36:23 +0000 (12:36 +0100)
Some tests use "accessibleMock" (= eval() code) where
it is completely unnecessary as not even a mock is needed.

Resolves: #89974
Releases: master
Change-Id: I6d44a251e670ec97787a45b68b40e8f4bef2946f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62547
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
40 files changed:
typo3/sysext/backend/Tests/Unit/Form/Element/InputHiddenElementTest.php
typo3/sysext/backend/Tests/Unit/Security/EmailLoginNotificationTest.php
typo3/sysext/beuser/Tests/Unit/Service/ModuleDataStorageServiceTest.php
typo3/sysext/core/Tests/Unit/LinkHandling/FileLinkHandlerTest.php
typo3/sysext/core/Tests/Unit/LinkHandling/FolderLinkHandlerTest.php
typo3/sysext/core/Tests/Unit/LinkHandling/LegacyLinkNotationConverterTest.php
typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php
typo3/sysext/core/Tests/Unit/Messaging/FlashMessageServiceTest.php
typo3/sysext/core/Tests/Unit/Resource/Processing/ProcessorRegistryTest.php
typo3/sysext/core/Tests/Unit/Routing/PageRouterTest.php
typo3/sysext/core/Tests/Unit/TypoScript/TemplateServiceTest.php
typo3/sysext/extbase/Tests/Unit/Configuration/AbstractConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Configuration/BackendConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Configuration/FrontendConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ArgumentTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ArgumentsTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/RequestTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/ResponseTest.php
typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php
typo3/sysext/extbase/Tests/Unit/Service/ImageScriptServiceTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractCompositeValidatorTest.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/AbstractValidatorTest.php
typo3/sysext/extensionmanager/Tests/Unit/Controller/DownloadControllerTest.php
typo3/sysext/extensionmanager/Tests/Unit/Domain/Model/DownloadQueueTest.php
typo3/sysext/extensionmanager/Tests/Unit/Report/ExtensionStatusTest.php
typo3/sysext/extensionmanager/Tests/Unit/Service/ExtensionManagementServiceTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/DependencyUtilityTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/ExtensionModelUtilityTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/AbstractFormViewHelperTest.php
typo3/sysext/form/Tests/Unit/Domain/Configuration/ConfigurationServiceTest.php
typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php
typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractSectionTest.php
typo3/sysext/form/Tests/Unit/Domain/Renderable/RenderableVariantTest.php
typo3/sysext/form/Tests/Unit/Domain/Runtime/FormRuntimeTest.php
typo3/sysext/form/Tests/Unit/Mvc/ProcessingRuleTest.php
typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php
typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php
typo3/sysext/install/Tests/Unit/ViewHelpers/Format/PhpErrorCodeViewHelperTest.php
typo3/sysext/t3editor/Tests/Unit/Registry/AddonRegistryTest.php
typo3/sysext/t3editor/Tests/Unit/Registry/ModeRegistryTest.php

index 0e75630..3ca0887 100644 (file)
@@ -15,6 +15,9 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Form\Element;
  */
 
 use TYPO3\CMS\Backend\Form\Element\InputHiddenElement;
+use TYPO3\CMS\Backend\Form\NodeFactory;
+use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -33,8 +36,8 @@ class InputHiddenElementTest extends UnitTestCase
                 'itemFormElValue' => 'bar'
             ]
         ];
-        $subject = $this->getAccessibleMock(InputHiddenElement::class, ['dummy'], [], '', false);
-        $subject->_set('data', $data);
+        GeneralUtility::addInstance(IconFactory::class, $this->prophesize(IconFactory::class)->reveal());
+        $subject = new InputHiddenElement($this->prophesize(NodeFactory::class)->reveal(), $data);
         $result = $subject->render();
         $additionalHiddenFieldsResult = array_pop($result['additionalHiddenFields']);
         self::assertStringContainsString('name="foo"', $additionalHiddenFieldsResult);
index 97be43d..dcd01e7 100644 (file)
@@ -16,8 +16,11 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Security;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
 use TYPO3\CMS\Backend\Security\EmailLoginNotification;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Mail\MailMessage;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class EmailLoginNotificationTest extends UnitTestCase
@@ -39,12 +42,12 @@ class EmailLoginNotificationTest extends UnitTestCase
             'email' => 'test@acme.com'
         ];
 
-        $subject = $this->getAccessibleMock(
-            EmailLoginNotification::class,
-            ['sendEmail', 'compileEmailBody']
-        );
-        $subject->expects(self::once())->method('sendEmail');
+        $mailMessage = $this->setUpMailMessageProphecy();
+
+        $subject = new EmailLoginNotification();
         $subject->emailAtLogin(['user' => $userData], $backendUser);
+
+        $mailMessage->send()->shouldHaveBeenCalled();
     }
 
     /**
@@ -65,12 +68,10 @@ class EmailLoginNotificationTest extends UnitTestCase
             'email' => 'test@acme.com'
         ];
 
-        $subject = $this->getAccessibleMock(
-            EmailLoginNotification::class,
-            ['sendEmail', 'compileEmailBody']
-        );
-        $subject->expects(self::never())->method('sendEmail');
+        $subject = new EmailLoginNotification();
         $subject->emailAtLogin(['user' => $userData], $backendUser);
+
+        // no additional assertion here, as the test would fail due to missing mail mocking if it actually tried to send an email
     }
 
     /**
@@ -91,12 +92,10 @@ class EmailLoginNotificationTest extends UnitTestCase
             'email' => 'dot.com'
         ];
 
-        $subject = $this->getAccessibleMock(
-            EmailLoginNotification::class,
-            ['sendEmail', 'compileEmailBody']
-        );
-        $subject->expects(self::never())->method('sendEmail');
+        $subject = new EmailLoginNotification();
         $subject->emailAtLogin(['user' => $userData], $backendUser);
+
+        // no additional assertion here, as the test would fail due to missing mail mocking if it actually tried to send an email
     }
 
     /**
@@ -118,15 +117,14 @@ class EmailLoginNotificationTest extends UnitTestCase
             'username' => 'karl'
         ];
 
-        $subject = $this->getAccessibleMock(
-            EmailLoginNotification::class,
-            ['sendEmail', 'compileEmailBody']
-        );
-        $subject->expects(self::once())->method('sendEmail')->with(
-            'typo3-admin@acme.com',
-            '[AdminLoginWarning] At "My TYPO3 Inc." from 127.0.0.1'
-        );
+        $mailMessage = $this->setUpMailMessageProphecy();
+
+        $subject = new EmailLoginNotification();
         $subject->emailAtLogin(['user' => $userData], $backendUser);
+
+        $mailMessage->send()->shouldHaveBeenCalledOnce();
+        $mailMessage->to('typo3-admin@acme.com')->shouldHaveBeenCalled();
+        $mailMessage->subject('[AdminLoginWarning] At "My TYPO3 Inc." from 127.0.0.1')->shouldHaveBeenCalled();
     }
 
     /**
@@ -148,15 +146,14 @@ class EmailLoginNotificationTest extends UnitTestCase
             'username' => 'karl'
         ];
 
-        $subject = $this->getAccessibleMock(
-            EmailLoginNotification::class,
-            ['sendEmail', 'compileEmailBody']
-        );
-        $subject->expects(self::once())->method('sendEmail')->with(
-            'typo3-admin@acme.com',
-            '[AdminLoginWarning] At "My TYPO3 Inc." from 127.0.0.1'
-        );
+        $mailMessage = $this->setUpMailMessageProphecy();
+
+        $subject = new EmailLoginNotification();
         $subject->emailAtLogin(['user' => $userData], $backendUser);
+
+        $mailMessage->subject('[AdminLoginWarning] At "My TYPO3 Inc." from 127.0.0.1')->shouldHaveBeenCalled();
+        $mailMessage->to('typo3-admin@acme.com')->shouldHaveBeenCalled();
+        $mailMessage->send()->shouldHaveBeenCalled();
     }
 
     /**
@@ -178,21 +175,20 @@ class EmailLoginNotificationTest extends UnitTestCase
             'username' => 'karl'
         ];
 
-        $subject = $this->getAccessibleMock(
-            EmailLoginNotification::class,
-            ['sendEmail', 'compileEmailBody']
-        );
-        $subject->expects(self::once())->method('sendEmail')->with(
-            'typo3-admin@acme.com',
-            '[LoginWarning] At "My TYPO3 Inc." from 127.0.0.1'
-        );
+        $mailMessage = $this->setUpMailMessageProphecy();
+
+        $subject = new EmailLoginNotification();
         $subject->emailAtLogin(['user' => $userData], $backendUser);
+
+        $mailMessage->to('typo3-admin@acme.com')->shouldHaveBeenCalled();
+        $mailMessage->subject('[LoginWarning] At "My TYPO3 Inc." from 127.0.0.1')->shouldHaveBeenCalled();
+        $mailMessage->send()->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function emailAtLoginSendsNoEmailIfAdminWarningIsEnabledAndNoAdminIsLoggingIn()
+    public function emailAtLoginSendsNoEmailIfAdminWarningIsEnabledAndNoAdminIsLoggingIn(): void
     {
         $_SERVER['HTTP_HOST'] = 'localhost';
         $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
@@ -208,11 +204,24 @@ class EmailLoginNotificationTest extends UnitTestCase
             'username' => 'karl'
         ];
 
-        $subject = $this->getAccessibleMock(
-            EmailLoginNotification::class,
-            ['sendEmail', 'compileEmailBody']
-        );
-        $subject->expects(self::never())->method('sendEmail');
+        $subject = new EmailLoginNotification();
         $subject->emailAtLogin(['user' => $userData], $backendUser);
+
+        // no additional assertion here as the test would fail due to not mocking the email API
+    }
+
+    /**
+     * @return \Prophecy\Prophecy\ObjectProphecy|\TYPO3\CMS\Core\Mail\MailMessage
+     */
+    protected function setUpMailMessageProphecy()
+    {
+        $mailMessage = $this->prophesize(MailMessage::class);
+        $mailMessage->subject(Argument::any())->willReturn($mailMessage->reveal());
+        $mailMessage->to(Argument::any())->willReturn($mailMessage->reveal());
+        $mailMessage->from(Argument::any())->willReturn($mailMessage->reveal());
+        $mailMessage->text(Argument::any())->willReturn($mailMessage->reveal());
+        $mailMessage->send()->willReturn(true);
+        GeneralUtility::addInstance(MailMessage::class, $mailMessage->reveal());
+        return $mailMessage;
     }
 }
index 0b67fb7..26dcf99 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Beuser\Tests\Unit\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Beuser\Service\ModuleDataStorageService;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -31,8 +32,7 @@ class ModuleDataStorageServiceTest extends UnitTestCase
         $GLOBALS['BE_USER']->uc = [];
         $GLOBALS['BE_USER']->uc['moduleData'] = [];
 
-        /** @var \TYPO3\CMS\Beuser\Service\ModuleDataStorageService $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Beuser\Service\ModuleDataStorageService::class, ['dummy'], [], '', false);
+        $subject = new ModuleDataStorageService();
         $objectManagerMock = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
         $moduleDataMock = $this->createMock(\TYPO3\CMS\Beuser\Domain\Model\ModuleData::class);
         $objectManagerMock
@@ -40,7 +40,7 @@ class ModuleDataStorageServiceTest extends UnitTestCase
             ->method('get')
             ->with(\TYPO3\CMS\Beuser\Domain\Model\ModuleData::class)
             ->willReturn($moduleDataMock);
-        $subject->_set('objectManager', $objectManagerMock);
+        $subject->injectObjectManager($objectManagerMock);
 
         self::assertSame($moduleDataMock, $subject->loadModuleData());
     }
index 4a6bd6e..309132f 100644 (file)
@@ -19,14 +19,17 @@ use TYPO3\CMS\Core\LinkHandling\FileLinkHandler;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class FileLinkHandlerTest extends UnitTestCase
 {
-    /**
-     * testing folders
-     */
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->resetSingletonInstances = true;
+    }
 
     /**
      * Data provider for pointing to files
@@ -64,13 +67,12 @@ class FileLinkHandlerTest extends UnitTestCase
      *
      * @test
      *
-     * @param string $input
+     * @param array $input
      * @param array  $expected
-     * @param string $finalString
      *
      * @dataProvider resolveParametersForFilesDataProvider
      */
-    public function resolveFileReferencesToSplitParameters($input, $expected, $finalString)
+    public function resolveFileReferencesToSplitParameters(array $input, array $expected): void
     {
         /** @var ResourceStorage|\PHPUnit\Framework\MockObject\MockObject $storageMock */
         $storage = $this->getMockBuilder(ResourceStorage::class)
@@ -83,13 +85,13 @@ class FileLinkHandlerTest extends UnitTestCase
 
         // fake methods to return proper objects
         $fileObject = new File(['identifier' => $expected['file'], 'name' => 'foobar.txt'], $storage);
-        $factory->expects(self::any())->method('getFileObject')->with($expected['file'])->willReturn($fileObject);
-        $factory->expects(self::any())->method('getFileObjectFromCombinedIdentifier')->with($expected['file'])->willReturn($fileObject);
+        $factory->method('getFileObject')->with($expected['file'])->willReturn($fileObject);
+        $factory->method('getFileObjectFromCombinedIdentifier')->with($expected['file'])->willReturn($fileObject);
         $expected['file'] = $fileObject;
+        GeneralUtility::setSingletonInstance(ResourceFactory::class, $factory);
+
+        $subject = new FileLinkHandler();
 
-        /** @var FileLinkHandler|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(FileLinkHandler::class, ['dummy']);
-        $subject->_set('resourceFactory', $factory);
         self::assertEquals($expected, $subject->resolveHandlerData($input));
     }
 
@@ -98,16 +100,16 @@ class FileLinkHandlerTest extends UnitTestCase
      *
      * @test
      *
-     * @param string $input
+     * @param array $input
      * @param array  $parameters
      * @param string $expected
      *
      * @dataProvider resolveParametersForFilesDataProvider
      */
-    public function splitParametersToUnifiedIdentifierForFiles($input, $parameters, $expected)
+    public function splitParametersToUnifiedIdentifierForFiles(array $input, array $parameters, string $expected): void
     {
         $fileObject = $this->getMockBuilder(File::class)
-            ->setMethods(['getUid', 'getIdentifier'])
+            ->onlyMethods(['getUid', 'getIdentifier'])
             ->disableOriginalConstructor()
             ->getMock();
 
@@ -116,7 +118,7 @@ class FileLinkHandlerTest extends UnitTestCase
             $uid = $parameters['file'];
         }
         $fileObject->expects(self::once())->method('getUid')->willReturn($uid);
-        $fileObject->expects(self::any())->method('getIdentifier')->willReturn($parameters['file']);
+        $fileObject->method('getIdentifier')->willReturn($parameters['file']);
         $parameters['file'] = $fileObject;
 
         $subject = new FileLinkHandler();
index 2eac564..fdbc3b3 100644 (file)
@@ -18,14 +18,16 @@ use TYPO3\CMS\Core\LinkHandling\FolderLinkHandler;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class FolderLinkHandlerTest extends UnitTestCase
 {
-
-    /**
-     * testing folders
-     */
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->resetSingletonInstances = true;
+    }
 
     /**
      * Data provider for pointing to files
@@ -34,7 +36,7 @@ class FolderLinkHandlerTest extends UnitTestCase
      *
      * @return array
      */
-    public function resolveParametersForFilesDataProvider()
+    public function resolveParametersForFilesDataProvider(): array
     {
         return [
             'folder without FAL - cool style' => [
@@ -65,13 +67,12 @@ class FolderLinkHandlerTest extends UnitTestCase
      *
      * @test
      *
-     * @param string $input
+     * @param array $input
      * @param array  $expected
-     * @param string $finalString
      *
      * @dataProvider resolveParametersForFilesDataProvider
      */
-    public function resolveFileReferencesToSplitParameters($input, $expected, $finalString)
+    public function resolveFileReferencesToSplitParameters(array $input, array $expected): void
     {
         $storage = $this->getMockBuilder(ResourceStorage::class)
             ->disableOriginalConstructor()
@@ -86,10 +87,10 @@ class FolderLinkHandlerTest extends UnitTestCase
         $factory->expects(self::once())->method('getFolderObjectFromCombinedIdentifier')->with($expected['folder'])
             ->willReturn($folderObject);
         $expected['folder'] = $folderObject;
+        GeneralUtility::setSingletonInstance(ResourceFactory::class, $factory);
+
+        $subject = new FolderLinkHandler();
 
-        /** @var FolderLinkHandler|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(FolderLinkHandler::class, ['dummy']);
-        $subject->_set('resourceFactory', $factory);
         self::assertEquals($expected, $subject->resolveHandlerData($input));
     }
 
@@ -98,16 +99,16 @@ class FolderLinkHandlerTest extends UnitTestCase
      *
      * @test
      *
-     * @param string $input
+     * @param array $input
      * @param array  $parameters
      * @param string $expected
      *
      * @dataProvider resolveParametersForFilesDataProvider
      */
-    public function splitParametersToUnifiedIdentifierForFiles($input, $parameters, $expected)
+    public function splitParametersToUnifiedIdentifierForFiles(array $input, array $parameters, string $expected): void
     {
         $folderObject = $this->getMockBuilder(Folder::class)
-            ->setMethods(['getCombinedIdentifier', 'getStorage', 'getIdentifier'])
+            ->onlyMethods(['getCombinedIdentifier', 'getStorage', 'getIdentifier'])
             ->disableOriginalConstructor()
             ->getMock();
 
@@ -118,8 +119,8 @@ class FolderLinkHandlerTest extends UnitTestCase
             ->disableOriginalConstructor()
             ->getMock(['getUid']);
         $storage->method('getUid')->willReturn($folderData[0]);
-        $folderObject->expects(self::any())->method('getStorage')->willReturn($storage);
-        $folderObject->expects(self::any())->method('getIdentifier')->willReturn($folderData[1]);
+        $folderObject->method('getStorage')->willReturn($storage);
+        $folderObject->method('getIdentifier')->willReturn($folderData[1]);
         $parameters['folder'] = $folderObject;
 
         $subject = new FolderLinkHandler();
index ac8891b..8422ce9 100644 (file)
@@ -22,11 +22,18 @@ use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class LegacyLinkNotationConverterTest extends UnitTestCase
 {
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->resetSingletonInstances = true;
+    }
+
     /**
      * Data to resolve strings to arrays and vice versa, external, mail, page
      *
@@ -148,7 +155,7 @@ class LegacyLinkNotationConverterTest extends UnitTestCase
      * @throws \TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException
      * @dataProvider resolveParametersForNonFilesDataProvider
      */
-    public function splitParametersToUnifiedIdentifier($input, $parameters, $expected): void
+    public function splitParametersToUnifiedIdentifier(string $input, array $parameters, string $expected): void
     {
         $subject = new LinkService();
         self::assertEquals($expected, $subject->asString($parameters));
@@ -237,11 +244,11 @@ class LegacyLinkNotationConverterTest extends UnitTestCase
         // fake methods to return proper objects
         if ($expected['type'] === LinkService::TYPE_FILE) {
             $fileObject = new File(['identifier' => $expected['file']], $storage);
-            $factory->expects(self::any())->method('getFileObjectFromCombinedIdentifier')->with($expected['file'])
+            $factory->method('getFileObjectFromCombinedIdentifier')->with($expected['file'])
                 ->willReturn($fileObject);
-            $factory->expects(self::any())->method('retrieveFileOrFolderObject')->with($expected['file'])
+            $factory->method('retrieveFileOrFolderObject')->with($expected['file'])
                 ->willReturn($fileObject);
-            $factory->expects(self::any())->method('getFileObject')->with($expected['file'])->willReturn($fileObject);
+            $factory->method('getFileObject')->with($expected['file'])->willReturn($fileObject);
             $expected['file'] = $fileObject;
         }
         // fake methods to return proper objects
@@ -250,16 +257,16 @@ class LegacyLinkNotationConverterTest extends UnitTestCase
                 $expected['folder'] = substr($expected['folder'], 5);
             }
             $folderObject = new Folder($storage, $expected['folder'], $expected['folder']);
-            $factory->expects(self::any())->method('retrieveFileOrFolderObject')->with($expected['folder'])
+            $factory->method('retrieveFileOrFolderObject')->with($expected['folder'])
                 ->willReturn($folderObject);
-            $factory->expects(self::any())->method('getFolderObjectFromCombinedIdentifier')->with($expected['folder'])
+            $factory->method('getFolderObjectFromCombinedIdentifier')->with($expected['folder'])
                 ->willReturn($folderObject);
             $expected['folder'] = $folderObject;
         }
+        GeneralUtility::setSingletonInstance(ResourceFactory::class, $factory);
+
+        $subject = new LegacyLinkNotationConverter();
 
-        /** @var LegacyLinkNotationConverter|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(LegacyLinkNotationConverter::class, ['dummy']);
-        $subject->_set('resourceFactory', $factory);
         self::assertEquals($expected, $subject->resolve($input));
     }
 
@@ -275,12 +282,12 @@ class LegacyLinkNotationConverterTest extends UnitTestCase
      * @throws \TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException
      * @dataProvider resolveParametersForFilesDataProvider
      */
-    public function splitParametersToUnifiedIdentifierForFiles($input, $parameters, $expected): void
+    public function splitParametersToUnifiedIdentifierForFiles(string $input, array $parameters, string $expected): void
     {
         // fake methods to return proper objects
         if ($parameters['type'] === LinkService::TYPE_FILE) {
             $fileObject = $this->getMockBuilder(File::class)
-                ->setMethods(['getUid', 'getIdentifier'])
+                ->onlyMethods(['getUid', 'getIdentifier'])
                 ->disableOriginalConstructor()
                 ->getMock();
             $uid = 0;
@@ -301,19 +308,19 @@ class LegacyLinkNotationConverterTest extends UnitTestCase
                 $parameters['folder'] = '0:' . $parameters['folder'];
             }
             $folderObject = $this->getMockBuilder(Folder::class)
-                ->setMethods(['getCombinedIdentifier', 'getStorage', 'getIdentifier'])
+                ->onlyMethods(['getCombinedIdentifier', 'getStorage', 'getIdentifier'])
                 ->disableOriginalConstructor()
                 ->getMock();
             $folderObject->expects(self::any())->method('getCombinedIdentifier')->willReturn($parameters['folder']);
             $folderData = explode(':', $parameters['folder']);
             /** @var ResourceStorage|\PHPUnit\Framework\MockObject\MockObject $storageMock */
             $storage = $this->getMockBuilder(ResourceStorage::class)
-                ->setMethods(['getUid'])
+                ->onlyMethods(['getUid'])
                 ->disableOriginalConstructor()
                 ->getMock();
             $storage->method('getUid')->willReturn($folderData[0]);
-            $folderObject->expects(self::any())->method('getStorage')->willReturn($storage);
-            $folderObject->expects(self::any())->method('getIdentifier')->willReturn($folderData[1]);
+            $folderObject->method('getStorage')->willReturn($storage);
+            $folderObject->method('getIdentifier')->willReturn($folderData[1]);
             $parameters['folder'] = $folderObject;
         }
 
@@ -349,7 +356,7 @@ class LegacyLinkNotationConverterTest extends UnitTestCase
      *
      * @dataProvider resolveThrowExceptionWithPharReferencesDataProvider
      */
-    public function resolveThrowExceptionWithPharReferences(string $pharUrl)
+    public function resolveThrowExceptionWithPharReferences(string $pharUrl): void
     {
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1530030673);
index 0df6071..56b8d4c 100644 (file)
@@ -42,24 +42,23 @@ class LocalizationFactoryTest extends UnitTestCase
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
 
-        /** @var $subject LocalizationFactory */
-        $localizationFactory = $this->getAccessibleMock(LocalizationFactory::class, ['localizationOverride']);
         $languageStore = $this->getMockBuilder(LanguageStore::class)
-            ->setMethods(['hasData', 'setConfiguration', 'getData', 'setData'])
+            ->onlyMethods(['hasData', 'setConfiguration', 'getData', 'setData'])
             ->getMock();
         $cacheInstance = $this->getMockBuilder(VariableFrontend::class)
-            ->setMethods(['get', 'set'])
+            ->onlyMethods(['get', 'set'])
             ->disableOriginalConstructor()
             ->getMock();
-        $localizationFactory->_set('store', $languageStore);
-        $localizationFactory->_set('cacheInstance', $cacheInstance);
+        $cacheManagerProphecy->getCache('l10n')->willReturn($cacheInstance);
+
+        $localizationFactory = new LocalizationFactory();
+        $localizationFactory->store = $languageStore;
         $languageStore->method('hasData')->willReturn(false);
         $languageStore->method('getData')->willReturn(['default' => []]);
         $languageStore->method('setConfiguration')->willThrowException(new FileNotFoundException('testing', 1476049512));
         $cacheInstance->method('get')->willReturn(false);
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'] = ['foo' => 'bar'];
 
-        $localizationFactory->expects(self::once())->method('localizationOverride');
         $localizationFactory->getParsedData('EXT:backend/Resources/Private/Language/locallang_layout.xlf', 'default');
     }
 }
index 852c87d..463b070 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Messaging;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -29,21 +30,13 @@ class FlashMessageServiceTest extends UnitTestCase
     protected function setUp(): void
     {
         parent::setUp();
-        $this->flashMessageService = $this->getAccessibleMock(\TYPO3\CMS\Core\Messaging\FlashMessageService::class, ['dummy']);
+        $this->flashMessageService = new FlashMessageService();
     }
 
     /**
      * @test
      */
-    public function flashMessageServiceInitiallyIsEmpty()
-    {
-        self::assertSame([], $this->flashMessageService->_get('flashMessageQueues'));
-    }
-
-    /**
-     * @test
-     */
-    public function getMessageQueueByIdentifierRegistersNewFlashmessageQueuesOnlyOnce()
+    public function getMessageQueueByIdentifierRegistersNewFlashmessageQueuesOnlyOnce(): void
     {
         self::assertSame(
             $this->flashMessageService->getMessageQueueByIdentifier('core.template.flashMessages'),
index 3e8aea3..843f0bc 100644 (file)
@@ -28,36 +28,19 @@ class ProcessorRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function getProcessorWhenOnlyOneIsRegistered()
+    public function getProcessorWhenOnlyOneIsRegistered(): void
     {
-        $subject = $this->getAccessibleMockForAbstractClass(
-            ProcessorRegistry::class,
-            [],
-            '',
-            false
-        );
-        $subject->_set('registeredProcessors', [
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors'] = [
             [
                 'className' => LocalImageProcessor::class,
             ]
-        ]);
-        $taskMock = $this->getAccessibleMockForAbstractClass(
-            AbstractTask::class,
-            [],
-            '',
-            false,
-            false,
-            false,
-            ['getType', 'getName']
-        );
-        $taskMock->expects(self::once())
-            ->method('getType')
-            ->willReturn('Image');
-        $taskMock->expects(self::once())
-            ->method('getName')
-            ->willReturn('CropScaleMask');
+        ];
+        $subject = new ProcessorRegistry();
+        $taskMock = $this->prophesize(AbstractTask::class);
+        $taskMock->getType()->willReturn('Image');
+        $taskMock->getName()->willReturn('CropScaleMask');
 
-        $processor = $subject->getProcessorByTask($taskMock);
+        $processor = $subject->getProcessorByTask($taskMock->reveal());
 
         self::assertInstanceOf(LocalImageProcessor::class, $processor);
     }
@@ -65,42 +48,21 @@ class ProcessorRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function getProcessorWhenNoneIsRegistered()
+    public function getProcessorWhenNoneIsRegistered(): void
     {
         $this->expectExceptionCode(1560876294);
 
-        $subject = $this->getAccessibleMockForAbstractClass(
-            ProcessorRegistry::class,
-            [],
-            '',
-            false,
-            false,
-            false
-        );
-        $taskMock = $this->getAccessibleMockForAbstractClass(
-            AbstractTask::class,
-            [],
-            '',
-            false,
-            false,
-            false
-        );
-
+        $subject = new ProcessorRegistry();
+        $taskMock = $this->prophesize(AbstractTask::class)->reveal();
         $subject->getProcessorByTask($taskMock);
     }
 
     /**
      * @test
      */
-    public function getProcessorWhenSameProcessorIsRegisteredTwice()
+    public function getProcessorWhenSameProcessorIsRegisteredTwice(): void
     {
-        $subject = $this->getAccessibleMockForAbstractClass(
-            ProcessorRegistry::class,
-            [],
-            '',
-            false
-        );
-        $subject->_set('registeredProcessors', [
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors'] = [
             'LocalImageProcessor' => [
                 'className' => LocalImageProcessor::class,
             ],
@@ -108,24 +70,13 @@ class ProcessorRegistryTest extends UnitTestCase
                 'className' => LocalImageProcessor::class,
                 'after' => 'LocalImageProcessor',
             ],
-        ]);
-        $taskMock = $this->getAccessibleMockForAbstractClass(
-            AbstractTask::class,
-            [],
-            '',
-            false,
-            false,
-            false,
-            ['getType', 'getName']
-        );
-        $taskMock->expects(self::once())
-            ->method('getType')
-            ->willReturn('Image');
-        $taskMock->expects(self::once())
-            ->method('getName')
-            ->willReturn('CropScaleMask');
+        ];
+        $subject =  new ProcessorRegistry();
+        $taskMock = $this->prophesize(AbstractTask::class);
+        $taskMock->getType()->willReturn('Image');
+        $taskMock->getName()->willReturn('CropScaleMask');
 
-        $processor = $subject->getProcessorByTask($taskMock);
+        $processor = $subject->getProcessorByTask($taskMock->reveal());
 
         self::assertInstanceOf(LocalImageProcessor::class, $processor);
     }
index 4c4a153..14c6281 100644 (file)
@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Routing\PageSlugCandidateProvider;
 use TYPO3\CMS\Core\Routing\RouteNotFoundException;
 use TYPO3\CMS\Core\Routing\SiteRouteResult;
 use TYPO3\CMS\Core\Site\Entity\Site;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class PageRouterTest extends UnitTestCase
@@ -36,7 +37,7 @@ class PageRouterTest extends UnitTestCase
     /**
      * @test
      */
-    public function matchRequestThrowsExceptionIfNoPreviousResultGiven()
+    public function matchRequestThrowsExceptionIfNoPreviousResultGiven(): void
     {
         $this->expectException(RouteNotFoundException::class);
         $this->expectExceptionCode(1555303496);
@@ -49,7 +50,7 @@ class PageRouterTest extends UnitTestCase
     /**
      * @test
      */
-    public function properSiteConfigurationFindsRoute()
+    public function properSiteConfigurationFindsRoute(): void
     {
         $incomingUrl = 'https://king.com/lotus-flower/en/mr-magpie/bloom';
         $pageRecord = ['uid' => 13, 'l10n_parent' => 0, 'slug' => '/mr-magpie/bloom'];
@@ -67,12 +68,11 @@ class PageRouterTest extends UnitTestCase
 
         $pageSlugCandidateProvider = $this->prophesize(PageSlugCandidateProvider::class);
         $pageSlugCandidateProvider->getCandidatesForPath('/mr-magpie/bloom', $language)->willReturn([$pageRecord]);
+        GeneralUtility::addInstance(PageSlugCandidateProvider::class, $pageSlugCandidateProvider->reveal());
 
         $request = new ServerRequest($incomingUrl, 'GET');
         $previousResult = new SiteRouteResult($request->getUri(), $site, $language, '/mr-magpie/bloom');
-        $subject = $this->getAccessibleMock(PageRouter::class, ['getSlugCandidateProvider'], [$site, []]);
-        $subject->expects(self::once())->method('getSlugCandidateProvider')->willReturn($pageSlugCandidateProvider->reveal());
-        $routeResult = $subject->matchRequest($request, $previousResult);
+        $routeResult = (new PageRouter($site))->matchRequest($request, $previousResult);
 
         $expectedRouteResult = new PageArguments(13, '0', [], [], []);
         self::assertEquals($expectedRouteResult, $routeResult);
@@ -99,12 +99,11 @@ class PageRouterTest extends UnitTestCase
         $language = $site->getDefaultLanguage();
         $pageSlugCandidateProvider = $this->prophesize(PageSlugCandidateProvider::class);
         $pageSlugCandidateProvider->getCandidatesForPath(Argument::cetera())->willReturn([$pageRecord]);
+        GeneralUtility::addInstance(PageSlugCandidateProvider::class, $pageSlugCandidateProvider->reveal());
 
         $request = new ServerRequest($incomingUrl, 'GET');
         $previousResult = new SiteRouteResult($request->getUri(), $site, $language, '/mr-magpie/bloom/');
-        $subject = $this->getAccessibleMock(PageRouter::class, ['getSlugCandidateProvider'], [$site, []]);
-        $subject->expects(self::once())->method('getSlugCandidateProvider')->willReturn($pageSlugCandidateProvider->reveal());
-        $routeResult = $subject->matchRequest($request, $previousResult);
+        $routeResult = (new PageRouter($site))->matchRequest($request, $previousResult);
 
         $expectedRouteResult = new PageArguments((int)$pageRecord['uid'], '0', []);
         self::assertEquals($expectedRouteResult, $routeResult);
index 5d1a9b9..b43780c 100644 (file)
@@ -65,11 +65,6 @@ class TemplateServiceTest extends UnitTestCase
         $GLOBALS['ACCESS_TIME'] = time();
         $this->packageManagerProphecy = $this->prophesize(PackageManager::class);
         $this->templateService = new TemplateService(new Context(), $this->packageManagerProphecy->reveal());
-        $this->templateServiceMock = $this->getAccessibleMock(
-            TemplateService::class,
-            ['dummy'],
-            [new Context(), $this->packageManagerProphecy->reveal()]
-        );
         $this->backupPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
     }
 
@@ -95,8 +90,9 @@ class TemplateServiceTest extends UnitTestCase
         $this->packageManagerProphecy->getActivePackages()->shouldNotBeCalled();
 
         $this->templateService->runThroughTemplates([], 0);
-        self::assertFalse(
-            in_array('test.Core.TypoScript = 1', $this->templateService->config, true)
+        self::assertNotContains(
+            'test.Core.TypoScript = 1',
+            $this->templateService->config
         );
     }
 
@@ -129,8 +125,9 @@ class TemplateServiceTest extends UnitTestCase
         $this->templateService->setProcessExtensionStatics(true);
         $this->templateService->runThroughTemplates([], 0);
 
-        self::assertTrue(
-            in_array('test.Core.TypoScript = 1', $this->templateService->config, true)
+        self::assertContains(
+            'test.Core.TypoScript = 1',
+            $this->templateService->config
         );
     }
 
@@ -155,9 +152,9 @@ class TemplateServiceTest extends UnitTestCase
             1 => ['uid' => 3, 'title' => 'newTitle3'],
         ];
 
-        $this->templateServiceMock->_set('rootLine', $originalRootline);
-        $this->templateServiceMock->updateRootlineData($updatedRootline);
-        self::assertEquals($expectedRootline, $this->templateServiceMock->_get('rootLine'));
+        $this->templateService->rootLine = $originalRootline;
+        $this->templateService->updateRootlineData($updatedRootline);
+        self::assertEquals($expectedRootline, $this->templateService->rootLine);
     }
 
     /**
@@ -178,7 +175,7 @@ class TemplateServiceTest extends UnitTestCase
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1370419654);
 
-        $this->templateServiceMock->_set('rootLine', $originalRootline);
-        $this->templateServiceMock->updateRootlineData($newInvalidRootline);
+        $this->templateService->rootLine = $originalRootline;
+        $this->templateService->updateRootlineData($newInvalidRootline);
     }
 }
index 87e5909..7a42f2f 100644 (file)
@@ -121,7 +121,7 @@ class AbstractConfigurationManagerTest extends UnitTestCase
             '',
             false
         );
-        $this->mockTypoScriptService = $this->getAccessibleMock(TypoScriptService::class);
+        $this->mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock();
         $this->abstractConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
     }
 
index 9e7aa6b..f474c42 100644 (file)
@@ -46,7 +46,7 @@ class BackendConfigurationManagerTest extends UnitTestCase
             '',
             false
         );
-        $this->mockTypoScriptService = $this->getAccessibleMock(\TYPO3\CMS\Core\TypoScript\TypoScriptService::class);
+        $this->mockTypoScriptService = $this->getMockBuilder(\TYPO3\CMS\Core\TypoScript\TypoScriptService::class)->getMock();
         $this->backendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
     }
 
index 098c12f..654a479 100644 (file)
@@ -52,7 +52,7 @@ class FrontendConfigurationManagerTest extends UnitTestCase
         $GLOBALS['TSFE'] = new \stdClass();
         $GLOBALS['TSFE']->tmpl = new \stdClass();
         $this->mockContentObject = $this->getMockBuilder(ContentObjectRenderer::class)
-            ->setMethods(['getTreeList'])
+            ->onlyMethods(['getTreeList'])
             ->getMock();
         $this->frontendConfigurationManager = $this->getAccessibleMock(
             FrontendConfigurationManager::class,
@@ -62,7 +62,7 @@ class FrontendConfigurationManagerTest extends UnitTestCase
             false
         );
         $this->frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
-        $this->mockTypoScriptService = $this->getAccessibleMock(TypoScriptService::class);
+        $this->mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock();
         $this->frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
     }
 
index acc5676..6413a75 100644 (file)
@@ -40,21 +40,21 @@ class ArgumentTest extends UnitTestCase
     protected function setUp(): void
     {
         parent::setUp();
-        $this->simpleValueArgument = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class, ['dummy'], ['someName', 'string']);
-        $this->objectArgument = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class, ['dummy'], ['someName', 'DateTime']);
+        $this->simpleValueArgument = new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('someName', 'string');
+        $this->objectArgument = new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('someName', 'DateTime');
         $this->mockPropertyMapper = $this->createMock(\TYPO3\CMS\Extbase\Property\PropertyMapper::class);
-        $this->simpleValueArgument->_set('propertyMapper', $this->mockPropertyMapper);
-        $this->objectArgument->_set('propertyMapper', $this->mockPropertyMapper);
+        $this->simpleValueArgument->injectPropertyMapper($this->mockPropertyMapper);
+        $this->objectArgument->injectPropertyMapper($this->mockPropertyMapper);
         $this->mockConfiguration = new \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfiguration();
         $propertyMappingConfiguranion = new \TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfiguration();
-        $this->simpleValueArgument->_set('propertyMappingConfiguration', $propertyMappingConfiguranion);
-        $this->objectArgument->_set('propertyMappingConfiguration', $propertyMappingConfiguranion);
+        $this->simpleValueArgument->injectPropertyMappingConfiguration($propertyMappingConfiguranion);
+        $this->objectArgument->injectPropertyMappingConfiguration($propertyMappingConfiguranion);
     }
 
     /**
      * @test
      */
-    public function constructingArgumentWithoutNameThrowsException()
+    public function constructingArgumentWithoutNameThrowsException(): void
     {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1232551853);
@@ -64,7 +64,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructingArgumentWithInvalidNameThrowsException()
+    public function constructingArgumentWithInvalidNameThrowsException(): void
     {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1187951688);
@@ -74,7 +74,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function passingDataTypeToConstructorReallySetsTheDataType()
+    public function passingDataTypeToConstructorReallySetsTheDataType(): void
     {
         self::assertEquals('string', $this->simpleValueArgument->getDataType(), 'The specified data type has not been set correctly.');
         self::assertEquals('someName', $this->simpleValueArgument->getName(), 'The specified name has not been set correctly.');
@@ -83,7 +83,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setShortNameProvidesFluentInterface()
+    public function setShortNameProvidesFluentInterface(): void
     {
         $returnedArgument = $this->simpleValueArgument->setShortName('x');
         self::assertSame($this->simpleValueArgument, $returnedArgument, 'The returned argument is not the original argument.');
@@ -92,7 +92,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @return array
      */
-    public function invalidShortNames()
+    public function invalidShortNames(): array
     {
         return [
             [''],
@@ -106,7 +106,7 @@ class ArgumentTest extends UnitTestCase
      * @dataProvider invalidShortNames
      * @param string $invalidShortName
      */
-    public function shortNameShouldThrowExceptionIfInvalid($invalidShortName)
+    public function shortNameShouldThrowExceptionIfInvalid($invalidShortName): void
     {
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1195824959);
@@ -116,7 +116,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function shortNameCanBeRetrievedAgain()
+    public function shortNameCanBeRetrievedAgain(): void
     {
         $this->simpleValueArgument->setShortName('x');
         self::assertEquals('x', $this->simpleValueArgument->getShortName());
@@ -125,7 +125,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setRequiredShouldProvideFluentInterfaceAndReallySetRequiredState()
+    public function setRequiredShouldProvideFluentInterfaceAndReallySetRequiredState(): void
     {
         $returnedArgument = $this->simpleValueArgument->setRequired(true);
         self::assertSame($this->simpleValueArgument, $returnedArgument, 'The returned argument is not the original argument.');
@@ -135,7 +135,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setDefaultValueShouldProvideFluentInterfaceAndReallySetDefaultValue()
+    public function setDefaultValueShouldProvideFluentInterfaceAndReallySetDefaultValue(): void
     {
         $returnedArgument = $this->simpleValueArgument->setDefaultValue('default');
         self::assertSame($this->simpleValueArgument, $returnedArgument, 'The returned argument is not the original argument.');
@@ -145,7 +145,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setValidatorShouldProvideFluentInterfaceAndReallySetValidator()
+    public function setValidatorShouldProvideFluentInterfaceAndReallySetValidator(): void
     {
         $mockValidator = $this->createMock(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class);
         $returnedArgument = $this->simpleValueArgument->setValidator($mockValidator);
@@ -156,7 +156,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setValueProvidesFluentInterface()
+    public function setValueProvidesFluentInterface(): void
     {
         $returnedArgument = $this->simpleValueArgument->setValue(null);
         self::assertSame($this->simpleValueArgument, $returnedArgument, 'The returned argument is not the original argument.');
@@ -165,10 +165,9 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setValueUsesNullAsIs()
+    public function setValueUsesNullAsIs(): void
     {
         $this->simpleValueArgument = new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('dummy', 'string');
-        $this->simpleValueArgument = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class, ['dummy'], ['dummy', 'string']);
         $this->simpleValueArgument->setValue(null);
         self::assertNull($this->simpleValueArgument->getValue());
     }
@@ -176,7 +175,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setValueUsesMatchingInstanceAsIs()
+    public function setValueUsesMatchingInstanceAsIs(): void
     {
         $this->mockPropertyMapper->expects(self::never())->method('convert');
         $this->objectArgument->setValue(new \DateTime());
@@ -185,7 +184,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @return \TYPO3\CMS\Extbase\Mvc\Controller\Argument $this
      */
-    protected function setupPropertyMapperAndSetValue()
+    protected function setupPropertyMapperAndSetValue(): \TYPO3\CMS\Extbase\Mvc\Controller\Argument
     {
         $this->mockPropertyMapper->expects(self::once())->method('convert')->with('someRawValue', 'string', $this->mockConfiguration)->willReturn('convertedValue');
         $this->mockPropertyMapper->expects(self::once())->method('getMessages')->willReturn(new \TYPO3\CMS\Extbase\Error\Result());
@@ -195,7 +194,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setValueShouldCallPropertyMapperCorrectlyAndStoreResultInValue()
+    public function setValueShouldCallPropertyMapperCorrectlyAndStoreResultInValue(): void
     {
         $this->setupPropertyMapperAndSetValue();
         self::assertSame('convertedValue', $this->simpleValueArgument->getValue());
@@ -205,7 +204,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setValueShouldBeFluentInterface()
+    public function setValueShouldBeFluentInterface(): void
     {
         self::assertSame($this->simpleValueArgument, $this->setupPropertyMapperAndSetValue());
     }
@@ -213,7 +212,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function setValueShouldSetValidationErrorsIfValidatorIsSetAndValidationFailed()
+    public function setValueShouldSetValidationErrorsIfValidatorIsSetAndValidationFailed(): void
     {
         $error = new \TYPO3\CMS\Extbase\Error\Error('Some Error', 1234);
         $mockValidator = $this->getMockBuilder(\TYPO3\CMS\Extbase\Validation\Validator\ValidatorInterface::class)
@@ -231,7 +230,7 @@ class ArgumentTest extends UnitTestCase
     /**
      * @test
      */
-    public function defaultPropertyMappingConfigurationDoesNotAllowCreationOrModificationOfObjects()
+    public function defaultPropertyMappingConfigurationDoesNotAllowCreationOrModificationOfObjects(): void
     {
         self::assertNull($this->simpleValueArgument->getPropertyMappingConfiguration()->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED));
         self::assertNull($this->simpleValueArgument->getPropertyMappingConfiguration()->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED));
index 29b03ca..166daa0 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Extbase\Mvc\Controller\Arguments;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -24,7 +25,7 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function argumentsObjectIsOfScopePrototype()
+    public function argumentsObjectIsOfScopePrototype(): void
     {
         $arguments1 = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $arguments2 = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
@@ -34,7 +35,7 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function addingAnArgumentManuallyWorks()
+    public function addingAnArgumentManuallyWorks(): void
     {
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $newArgument = new \TYPO3\CMS\Extbase\Mvc\Controller\Argument('argumentName1234', 'dummyValue');
@@ -45,20 +46,20 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function addingAnArgumentReplacesArgumentWithSameName()
+    public function addingAnArgumentReplacesArgumentWithSameName(): void
     {
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $mockFirstArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockFirstArgument->expects(self::any())->method('getName')->willReturn('argumentName1234');
+        $mockFirstArgument->method('getName')->willReturn('argumentName1234');
         $arguments->addArgument($mockFirstArgument);
         $mockSecondArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockSecondArgument->expects(self::any())->method('getName')->willReturn('argumentName1234');
+        $mockSecondArgument->method('getName')->willReturn('argumentName1234');
         $arguments->addArgument($mockSecondArgument);
         self::assertSame($mockSecondArgument, $arguments->getArgument('argumentName1234'), 'The added and retrieved argument is not the same.');
     }
@@ -66,13 +67,13 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function addNewArgumentProvidesFluentInterface()
+    public function addNewArgumentProvidesFluentInterface(): void
     {
         $mockArgument = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class);
         $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
         $mockObjectManager->expects(self::once())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)->willReturn($mockArgument);
-        $arguments = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, ['dummy']);
-        $arguments->_set('objectManager', $mockObjectManager);
+        $arguments = new Arguments();
+        $arguments->injectObjectManager($mockObjectManager);
         $newArgument = $arguments->addNewArgument('someArgument');
         self::assertSame($newArgument, $mockArgument);
     }
@@ -80,13 +81,13 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function addingArgumentThroughArrayAccessWorks()
+    public function addingArgumentThroughArrayAccessWorks(): void
     {
         $mockArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument->expects(self::any())->method('getName')->willReturn('argumentName1234');
+        $mockArgument->method('getName')->willReturn('argumentName1234');
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $arguments[] = $mockArgument;
         self::assertTrue($arguments->hasArgument('argumentName1234'), 'Added argument does not exist.');
@@ -96,13 +97,13 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function retrievingArgumentThroughArrayAccessWorks()
+    public function retrievingArgumentThroughArrayAccessWorks(): void
     {
         $mockArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument->expects(self::any())->method('getName')->willReturn('argumentName1234');
+        $mockArgument->method('getName')->willReturn('argumentName1234');
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $arguments[] = $mockArgument;
         self::assertSame($mockArgument, $arguments['argumentName1234'], 'Argument retrieved by array access is not the one we added.');
@@ -111,7 +112,7 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function getArgumentWithNonExistingArgumentNameThrowsException()
+    public function getArgumentWithNonExistingArgumentNameThrowsException(): void
     {
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         try {
@@ -124,13 +125,13 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function issetReturnsCorrectResult()
+    public function issetReturnsCorrectResult(): void
     {
         $mockArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument->expects(self::any())->method('getName')->willReturn('argumentName1234');
+        $mockArgument->method('getName')->willReturn('argumentName1234');
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         self::assertFalse(isset($arguments['argumentName1234']), 'isset() did not return FALSE.');
         $arguments[] = $mockArgument;
@@ -140,23 +141,23 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function getArgumentNamesReturnsNamesOfAddedArguments()
+    public function getArgumentNamesReturnsNamesOfAddedArguments(): void
     {
         $mockArgument1 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument1->expects(self::any())->method('getName')->willReturn('argumentName1');
+        $mockArgument1->method('getName')->willReturn('argumentName1');
         $mockArgument2 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument2->expects(self::any())->method('getName')->willReturn('argumentName2');
+        $mockArgument2->method('getName')->willReturn('argumentName2');
         $mockArgument3 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument3->expects(self::any())->method('getName')->willReturn('argumentName3');
+        $mockArgument3->method('getName')->willReturn('argumentName3');
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $arguments[] = $mockArgument1;
         $arguments[] = $mockArgument2;
@@ -168,26 +169,26 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function getArgumentShortNamesReturnsShortNamesOfAddedArguments()
+    public function getArgumentShortNamesReturnsShortNamesOfAddedArguments(): void
     {
         $mockArgument1 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName', 'getShortName'])
+            ->onlyMethods(['getName', 'getShortName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument1->expects(self::any())->method('getName')->willReturn('argumentName1');
-        $mockArgument1->expects(self::any())->method('getShortName')->willReturn('a');
+        $mockArgument1->method('getName')->willReturn('argumentName1');
+        $mockArgument1->method('getShortName')->willReturn('a');
         $mockArgument2 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName', 'getShortName'])
+            ->onlyMethods(['getName', 'getShortName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument2->expects(self::any())->method('getName')->willReturn('argumentName2');
-        $mockArgument2->expects(self::any())->method('getShortName')->willReturn('b');
+        $mockArgument2->method('getName')->willReturn('argumentName2');
+        $mockArgument2->method('getShortName')->willReturn('b');
         $mockArgument3 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName', 'getShortName'])
+            ->onlyMethods(['getName', 'getShortName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument3->expects(self::any())->method('getName')->willReturn('argumentName3');
-        $mockArgument3->expects(self::any())->method('getShortName')->willReturn('c');
+        $mockArgument3->method('getName')->willReturn('argumentName3');
+        $mockArgument3->method('getShortName')->willReturn('c');
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $arguments[] = $mockArgument1;
         $arguments[] = $mockArgument2;
@@ -199,17 +200,17 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function addNewArgumentCreatesAndAddsNewArgument()
+    public function addNewArgumentCreatesAndAddsNewArgument(): void
     {
         $mockArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument->expects(self::any())->method('getName')->willReturn('dummyName');
+        $mockArgument->method('getName')->willReturn('dummyName');
         $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
         $mockObjectManager->expects(self::once())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)->willReturn($mockArgument);
-        $arguments = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, ['dummy']);
-        $arguments->_set('objectManager', $mockObjectManager);
+        $arguments = new Arguments();
+        $arguments->injectObjectManager($mockObjectManager);
         $addedArgument = $arguments->addNewArgument('dummyName');
         self::assertInstanceOf(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class, $addedArgument, 'addNewArgument() either did not add a new argument or did not return it.');
         $retrievedArgument = $arguments['dummyName'];
@@ -219,45 +220,45 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function addNewArgumentAssumesTextDataTypeByDefault()
+    public function addNewArgumentAssumesTextDataTypeByDefault(): void
     {
         $mockArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName'])
+            ->onlyMethods(['getName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument->expects(self::any())->method('getName')->willReturn('dummyName');
+        $mockArgument->method('getName')->willReturn('dummyName');
         $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
         $mockObjectManager->expects(self::once())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class, 'dummyName', 'Text')->willReturn($mockArgument);
-        $arguments = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, ['dummy']);
-        $arguments->_set('objectManager', $mockObjectManager);
+        $arguments = new Arguments();
+        $arguments->injectObjectManager($mockObjectManager);
         $arguments->addNewArgument('dummyName');
     }
 
     /**
      * @test
      */
-    public function addNewArgumentCanAddArgumentsMarkedAsRequired()
+    public function addNewArgumentCanAddArgumentsMarkedAsRequired(): void
     {
         $mockArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName', 'setRequired'])
+            ->onlyMethods(['getName', 'setRequired'])
             ->disableOriginalConstructor()
             ->getMock();
         $mockArgument->expects(self::once())->method('getName')->willReturn('dummyName');
         $mockArgument->expects(self::once())->method('setRequired')->with(true);
         $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
         $mockObjectManager->expects(self::once())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class, 'dummyName', 'Text')->willReturn($mockArgument);
-        $arguments = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, ['dummy']);
-        $arguments->_set('objectManager', $mockObjectManager);
+        $arguments = new Arguments();
+        $arguments->injectObjectManager($mockObjectManager);
         $arguments->addNewArgument('dummyName', 'Text', true);
     }
 
     /**
      * @test
      */
-    public function addNewArgumentCanAddArgumentsMarkedAsOptionalWithDefaultValues()
+    public function addNewArgumentCanAddArgumentsMarkedAsOptionalWithDefaultValues(): void
     {
         $mockArgument = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName', 'setRequired', 'setDefaultValue'])
+            ->onlyMethods(['getName', 'setRequired', 'setDefaultValue'])
             ->disableOriginalConstructor()
             ->getMock();
         $mockArgument->expects(self::once())->method('getName')->willReturn('dummyName');
@@ -265,15 +266,15 @@ class ArgumentsTest extends UnitTestCase
         $mockArgument->expects(self::once())->method('setDefaultValue')->with('someDefaultValue');
         $mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
         $mockObjectManager->expects(self::once())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class, 'dummyName', 'Text')->willReturn($mockArgument);
-        $arguments = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Controller\Arguments::class, ['dummy']);
-        $arguments->_set('objectManager', $mockObjectManager);
+        $arguments = new Arguments();
+        $arguments->injectObjectManager($mockObjectManager);
         $arguments->addNewArgument('dummyName', 'Text', false, 'someDefaultValue');
     }
 
     /**
      * @test
      */
-    public function callingInvalidMethodThrowsException()
+    public function callingInvalidMethodThrowsException(): void
     {
         $this->expectException(\LogicException::class);
         $this->expectExceptionCode(1210858451);
@@ -284,18 +285,18 @@ class ArgumentsTest extends UnitTestCase
     /**
      * @test
      */
-    public function removeAllClearsAllArguments()
+    public function removeAllClearsAllArguments(): void
     {
         $mockArgument1 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName', 'getShortName'])
+            ->onlyMethods(['getName', 'getShortName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument1->expects(self::any())->method('getName')->willReturn('argumentName1');
+        $mockArgument1->method('getName')->willReturn('argumentName1');
         $mockArgument2 = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Controller\Argument::class)
-            ->setMethods(['getName', 'getShortName'])
+            ->onlyMethods(['getName', 'getShortName'])
             ->disableOriginalConstructor()
             ->getMock();
-        $mockArgument2->expects(self::any())->method('getName')->willReturn('argumentName2');
+        $mockArgument2->method('getName')->willReturn('argumentName2');
         $arguments = new \TYPO3\CMS\Extbase\Mvc\Controller\Arguments();
         $arguments[] = $mockArgument1;
         $arguments[] = $mockArgument2;
index e265e39..3f486eb 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc;
  * The TYPO3 project - inspiring people to share!
  */
 use TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentNameException;
+use TYPO3\CMS\Extbase\Mvc\Request;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -24,7 +25,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function aSingleArgumentCanBeSetWithSetArgumentAndRetrievedWithGetArgument()
+    public function aSingleArgumentCanBeSetWithSetArgumentAndRetrievedWithGetArgument(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         $request->setArgument('someArgumentName', 'theValue');
@@ -34,7 +35,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentThrowsExceptionIfTheGivenArgumentNameIsNoString()
+    public function setArgumentThrowsExceptionIfTheGivenArgumentNameIsNoString(): void
     {
         $this->expectException(InvalidArgumentNameException::class);
         $this->expectExceptionCode(1210858767);
@@ -45,7 +46,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentThrowsExceptionIfTheGivenArgumentNameIsAnEmptyString()
+    public function setArgumentThrowsExceptionIfTheGivenArgumentNameIsAnEmptyString(): void
     {
         $this->expectException(InvalidArgumentNameException::class);
         $this->expectExceptionCode(1210858767);
@@ -56,7 +57,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentsOverridesAllExistingArguments()
+    public function setArgumentsOverridesAllExistingArguments(): void
     {
         $arguments = ['key1' => 'value1', 'key2' => 'value2'];
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
@@ -69,10 +70,10 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentsCallsSetArgumentForEveryArrayEntry()
+    public function setArgumentsCallsSetArgumentForEveryArrayEntry(): void
     {
         $request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)
-            ->setMethods(['setArgument'])
+            ->onlyMethods(['setArgument'])
             ->getMock();
         $request->expects(self::at(0))->method('setArgument')->with('key1', 'value1');
         $request->expects(self::at(1))->method('setArgument')->with('key2', 'value2');
@@ -82,12 +83,12 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentShouldSetControllerExtensionNameIfPackageKeyIsGiven()
+    public function setArgumentShouldSetControllerExtensionNameIfPackageKeyIsGiven(): void
     {
         $request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)
-            ->setMethods(['setControllerExtensionName'])
+            ->onlyMethods(['setControllerExtensionName'])
             ->getMock();
-        $request->expects(self::any())->method('setControllerExtensionName')->with('MyExtension');
+        $request->method('setControllerExtensionName')->with('MyExtension');
         $request->setArgument('@extension', 'MyExtension');
         self::assertFalse($request->hasArgument('@extension'));
     }
@@ -95,12 +96,12 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentShouldSetControllerSubpackageKeyIfSubpackageKeyIsGiven()
+    public function setArgumentShouldSetControllerSubpackageKeyIfSubpackageKeyIsGiven(): void
     {
         $request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)
-            ->setMethods(['setControllerSubpackageKey'])
+            ->onlyMethods(['setControllerSubpackageKey'])
             ->getMock();
-        $request->expects(self::any())->method('setControllerSubpackageKey')->with('MySubPackage');
+        $request->method('setControllerSubpackageKey')->with('MySubPackage');
         $request->setArgument('@subpackage', 'MySubPackage');
         self::assertFalse($request->hasArgument('@subpackage'));
     }
@@ -108,12 +109,12 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentShouldSetControllerNameIfControllerIsGiven()
+    public function setArgumentShouldSetControllerNameIfControllerIsGiven(): void
     {
         $request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)
-            ->setMethods(['setControllerName'])
+            ->onlyMethods(['setControllerName'])
             ->getMock();
-        $request->expects(self::any())->method('setControllerName')->with('MyController');
+        $request->method('setControllerName')->with('MyController');
         $request->setArgument('@controller', 'MyController');
         self::assertFalse($request->hasArgument('@controller'));
     }
@@ -121,12 +122,12 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentShouldSetControllerActionNameIfActionIsGiven()
+    public function setArgumentShouldSetControllerActionNameIfActionIsGiven(): void
     {
         $request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)
-            ->setMethods(['setControllerActionName'])
+            ->onlyMethods(['setControllerActionName'])
             ->getMock();
-        $request->expects(self::any())->method('setControllerActionName')->with('foo');
+        $request->method('setControllerActionName')->with('foo');
         $request->setArgument('@action', 'foo');
         self::assertFalse($request->hasArgument('@action'));
     }
@@ -134,12 +135,12 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentShouldSetFormatIfFormatIsGiven()
+    public function setArgumentShouldSetFormatIfFormatIsGiven(): void
     {
         $request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)
-            ->setMethods(['setFormat'])
+            ->onlyMethods(['setFormat'])
             ->getMock();
-        $request->expects(self::any())->method('setFormat')->with('txt');
+        $request->method('setFormat')->with('txt');
         $request->setArgument('@format', 'txt');
         self::assertFalse($request->hasArgument('@format'));
     }
@@ -147,7 +148,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function internalArgumentsShouldNotBeReturnedAsNormalArgument()
+    public function internalArgumentsShouldNotBeReturnedAsNormalArgument(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         $request->setArgument('__referrer', 'foo');
@@ -157,7 +158,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function internalArgumentsShouldBeStoredAsInternalArguments()
+    public function internalArgumentsShouldBeStoredAsInternalArguments(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         $request->setArgument('__referrer', 'foo');
@@ -167,7 +168,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function hasInternalArgumentShouldReturnNullIfArgumentNotFound()
+    public function hasInternalArgumentShouldReturnNullIfArgumentNotFound(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         self::assertNull($request->getInternalArgument('__nonExistingInternalArgument'));
@@ -176,7 +177,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function setArgumentAcceptsObjectIfArgumentIsInternal()
+    public function setArgumentAcceptsObjectIfArgumentIsInternal(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         $object = new \stdClass();
@@ -187,7 +188,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function multipleArgumentsCanBeSetWithSetArgumentsAndRetrievedWithGetArguments()
+    public function multipleArgumentsCanBeSetWithSetArgumentsAndRetrievedWithGetArguments(): void
     {
         $arguments = [
             'firstArgument' => 'firstValue',
@@ -202,7 +203,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function hasArgumentTellsIfAnArgumentExists()
+    public function hasArgumentTellsIfAnArgumentExists(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         $request->setArgument('existingArgument', 'theValue');
@@ -216,7 +217,7 @@ class RequestTest extends UnitTestCase
     public function theActionNameCanBeSetAndRetrieved()
     {
         $request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)
-            ->setMethods(['getControllerObjectName'])
+            ->onlyMethods(['getControllerObjectName'])
             ->disableOriginalConstructor()
             ->getMock();
         $request->expects(self::once())->method('getControllerObjectName')->willReturn('');
@@ -227,7 +228,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function theRepresentationFormatCanBeSetAndRetrieved()
+    public function theRepresentationFormatCanBeSetAndRetrieved(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         $request->setFormat('html');
@@ -237,7 +238,7 @@ class RequestTest extends UnitTestCase
     /**
      * @test
      */
-    public function aFlagCanBeSetIfTheRequestNeedsToBeDispatchedAgain()
+    public function aFlagCanBeSetIfTheRequestNeedsToBeDispatchedAgain(): void
     {
         $request = new \TYPO3\CMS\Extbase\Mvc\Request();
         self::assertFalse($request->isDispatched());
@@ -250,7 +251,7 @@ class RequestTest extends UnitTestCase
      *
      * @return array
      */
-    public function controllerArgumentsAndExpectedObjectName()
+    public function controllerArgumentsAndExpectedObjectName(): array
     {
         return [
             'Vendor TYPO3\CMS, extension, controller given' => [
@@ -295,16 +296,16 @@ class RequestTest extends UnitTestCase
      * @param string $controllerObjectName
      * @test
      */
-    public function setControllerObjectNameResolvesControllerObjectNameArgumentsCorrectly($controllerArguments, $controllerObjectName)
+    public function setControllerObjectNameResolvesControllerObjectNameArgumentsCorrectly($controllerArguments, $controllerObjectName): void
     {
         /** @var $request \TYPO3\CMS\Extbase\Mvc\Request */
-        $request = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, ['dummy'], [], '', false);
+        $request = new Request();
         $request->setControllerObjectName($controllerObjectName);
 
         $actualControllerArguments = [
-            'extensionName' => $request->_get('controllerExtensionName'),
-            'subpackageKey' => $request->_get('controllerSubpackageKey'),
-            'controllerName' => $request->_get('controllerName'),
+            'extensionName' => $request->getControllerExtensionName(),
+            'subpackageKey' => $request->getControllerSubpackageKey(),
+            'controllerName' => $request->getControllerName(),
         ];
 
         self::assertSame($controllerArguments, $actualControllerArguments);
index 7fab2b0..9c9a055 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Extbase\Mvc\Response;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -24,56 +25,56 @@ class ResponseTest extends UnitTestCase
     /**
      * @var \TYPO3\CMS\Extbase\Mvc\Response|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
      */
-    protected $mockResponse;
+    protected $response;
 
     protected function setUp(): void
     {
         parent::setUp();
-        $this->mockResponse = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Response::class, ['dummy']);
+        $this->response = new Response();
     }
 
     /**
      * @test
      */
-    public function propertyContentInitiallyIsNull()
+    public function propertyContentInitiallyIsNull(): void
     {
-        self::assertNull($this->mockResponse->_get('content'));
+        self::assertNull($this->response->getContent());
     }
 
     /**
      * @test
      */
-    public function setContentSetsContentCorrectly()
+    public function setContentSetsContentCorrectly(): void
     {
-        $this->mockResponse->setContent('foo');
-        self::assertSame('foo', $this->mockResponse->_get('content'));
+        $this->response->setContent('foo');
+        self::assertSame('foo', $this->response->getContent());
     }
 
     /**
      * @test
      */
-    public function appendContentAppendsContentCorrectly()
+    public function appendContentAppendsContentCorrectly(): void
     {
-        $this->mockResponse->_set('content', 'foo');
-        $this->mockResponse->appendContent('bar');
-        self::assertSame('foobar', $this->mockResponse->_get('content'));
+        $this->response->setContent('foo');
+        $this->response->appendContent('bar');
+        self::assertSame('foobar', $this->response->getContent());
     }
 
     /**
      * @test
      */
-    public function getContentReturnsContentCorrectly()
+    public function getContentReturnsContentCorrectly(): void
     {
-        $this->mockResponse->_set('content', 'foo');
-        self::assertSame('foo', $this->mockResponse->getContent());
+        $this->response->setContent('foo');
+        self::assertSame('foo', $this->response->getContent());
     }
 
     /**
      * @test
      */
-    public function __toStringReturnsActualContent()
+    public function __toStringReturnsActualContent(): void
     {
-        $this->mockResponse->_set('content', 'foo');
-        self::assertSame('foo', (string)$this->mockResponse);
+        $this->response->setContent('foo');
+        self::assertSame('foo', (string)$this->response);
     }
 }
index 8532a1e..ea05453 100644 (file)
@@ -53,9 +53,9 @@ class ExtensionServiceTest extends UnitTestCase
     {
         parent::setUp();
         $GLOBALS['TSFE'] = new \stdClass();
-        $this->extensionService = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Service\ExtensionService::class, ['dummy']);
+        $this->extensionService = new \TYPO3\CMS\Extbase\Service\ExtensionService();
         $this->mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
-        $this->extensionService->_set('configurationManager', $this->mockConfigurationManager);
+        $this->extensionService->injectConfigurationManager($this->mockConfigurationManager);
         $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'] = [
             'ExtensionName' => [
                 'plugins' => [
index 20755f1..3f0b953 100644 (file)
@@ -60,11 +60,10 @@ class ImageScriptServiceTest extends UnitTestCase
      */
     public function fileIsUnwrappedFromReferenceForProcessing(): void
     {
-        $reference = $this->getAccessibleMock(FileReference::class, [], [], '', false);
+        $reference = $this->getMockBuilder(FileReference::class)->disableOriginalConstructor()->getMock();
         $file = $this->createMock(File::class);
         $file->expects(self::once())->method('process')->willReturn($this->createMock(ProcessedFile::class));
         $reference->expects(self::once())->method('getOriginalFile')->willReturn($file);
-        $reference->_set('file', $file);
 
         $this->subject->applyProcessingInstructions($reference, []);
     }
index 039459c..b76eb83 100644 (file)
@@ -25,50 +25,50 @@ class AbstractCompositeValidatorTest extends UnitTestCase
     /**
      * @test
      */
-    public function validatorAcceptsSupportedOptions()
+    public function validatorAcceptsSupportedOptions(): void
     {
         $inputOptions = [
             'requiredOption' => 666,
             'demoOption' => 42
         ];
         $expectedOptions = $inputOptions;
-        $validator = $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
-        self::assertSame($expectedOptions, $validator->_get('options'));
+        $validator = new AbstractCompositeValidatorClass($inputOptions);
+        self::assertSame($expectedOptions, $validator->getOptions());
     }
 
     /**
      * @test
      */
-    public function validatorHasDefaultOptions()
+    public function validatorHasDefaultOptions(): void
     {
         $inputOptions = ['requiredOption' => 666];
         $expectedOptions = [
             'requiredOption' => 666,
             'demoOption' => PHP_INT_MAX
         ];
-        $validator = $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
-        self::assertSame($expectedOptions, $validator->_get('options'));
+        $validator = new AbstractCompositeValidatorClass($inputOptions);
+        self::assertSame($expectedOptions, $validator->getOptions());
     }
 
     /**
      * @test
      */
-    public function validatorThrowsExceptionOnNotSupportedOptions()
+    public function validatorThrowsExceptionOnNotSupportedOptions(): void
     {
         $inputOptions = ['invalidoption' => 42];
         $this->expectException(\TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException::class);
         $this->expectExceptionCode(1339079804);
-        $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
+        new AbstractCompositeValidatorClass($inputOptions);
     }
 
     /**
      * @test
      */
-    public function validatorThrowsExceptionOnMissingRequiredOptions()
+    public function validatorThrowsExceptionOnMissingRequiredOptions(): void
     {
         $inputOptions = [];
         $this->expectException(\TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException::class);
         $this->expectExceptionCode(1339163922);
-        $this->getAccessibleMock(AbstractCompositeValidatorClass::class, ['dummy'], [$inputOptions]);
+        new AbstractCompositeValidatorClass($inputOptions);
     }
 }
index 5af49dd..fc69fbd 100644 (file)
@@ -25,50 +25,50 @@ class AbstractValidatorTest extends UnitTestCase
     /**
      * @test
      */
-    public function validatorAcceptsSupportedOptions()
+    public function validatorAcceptsSupportedOptions(): void
     {
         $inputOptions = [
             'requiredOption' => 666,
             'demoOption' => 42
         ];
         $expectedOptions = $inputOptions;
-        $validator = $this->getAccessibleMock(AbstractValidatorClass::class, ['dummy'], [$inputOptions]);
-        self::assertSame($expectedOptions, $validator->_get('options'));
+        $validator = new AbstractValidatorClass($inputOptions);
+        self::assertSame($expectedOptions, $validator->getOptions());
     }
 
     /**
      * @test
      */
-    public function validatorHasDefaultOptions()
+    public function validatorHasDefaultOptions(): void
     {
         $inputOptions = ['requiredOption' => 666];
         $expectedOptions = [
             'requiredOption' => 666,
             'demoOption' => PHP_INT_MAX
         ];
-        $validator = $this->getAccessibleMock(AbstractValidatorClass::class, ['dummy'], [$inputOptions]);
-        self::assertSame($expectedOptions, $validator->_get('options'));
+        $validator = new AbstractValidatorClass($inputOptions);
+        self::assertSame($expectedOptions, $validator->getOptions());
     }
 
     /**
      * @test
      */
-    public function validatorThrowsExceptionOnNotSupportedOptions()
+    public function validatorThrowsExceptionOnNotSupportedOptions(): void
     {
         $inputOptions = ['invalidoption' => 42];
         $this->expectException(\TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException::class);
         $this->expectExceptionCode(1379981890);
-        $this->getAccessibleMock(AbstractValidatorClass::class, ['dummy'], [$inputOptions]);
+        new AbstractValidatorClass($inputOptions);
     }
 
     /**
      * @test
      */
-    public function validatorThrowsExceptionOnMissingRequiredOptions()
+    public function validatorThrowsExceptionOnMissingRequiredOptions(): void
     {
         $inputOptions = [];
         $this->expectException(\TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationOptionsException::class);
         $this->expectExceptionCode(1379981891);
-        $this->getAccessibleMock(AbstractValidatorClass::class, ['dummy'], [$inputOptions]);
+        new AbstractValidatorClass($inputOptions);
     }
 }
index 8ea2957..3bcd883 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Controller;
  */
 
 use PHPUnit\Framework\MockObject\MockObject;
+use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -25,14 +26,14 @@ class DownloadControllerTest extends UnitTestCase
     /**
      * @test
      */
-    public function installFromTerReturnsArrayWithBooleanResultAndErrorArrayWhenExtensionManagerExceptionIsThrown()
+    public function installFromTerReturnsArrayWithBooleanResultAndErrorArrayWhenExtensionManagerExceptionIsThrown(): void
     {
         $dummyExceptionMessage = 'exception message';
         $dummyException = new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException($dummyExceptionMessage, 1476108614);
 
         $dummyExtensionName = 'dummy_extension';
-        $dummyExtension = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class)->getMock();
-        $dummyExtension->expects(self::any())->method('getExtensionKey')->willReturn($dummyExtensionName);
+        $dummyExtension = new Extension();
+        $dummyExtension->setExtensionKey($dummyExtensionName);
 
         /** @var \TYPO3\CMS\Extensionmanager\Utility\DownloadUtility|MockObject $downloadUtilityMock */
         $downloadUtilityMock = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Utility\DownloadUtility::class)->getMock();
index b190fc7..a9ae584 100644 (file)
@@ -13,6 +13,9 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Model;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue;
+use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -22,33 +25,31 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class DownloadQueueTest extends UnitTestCase
 {
     /**
-     * @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue
+     * @var \TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue
      */
-    protected $downloadQueueMock;
+    protected $downloadQueue;
 
     /**
-     * @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\CMS\Extensionmanager\Domain\Model\Extension
+     * @var \TYPO3\CMS\Extensionmanager\Domain\Model\Extension
      */
-    protected $extensionMock;
+    protected $extension;
 
     protected function setUp(): void
     {
         parent::setUp();
-        $this->downloadQueueMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue::class, ['dummy']);
-        $this->extensionMock = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class)
-            ->setMethods(['dummy'])
-            ->getMock();
-        $this->extensionMock->setExtensionKey('foobar');
-        $this->extensionMock->setVersion('1.0.0');
+        $this->downloadQueue = new DownloadQueue();
+        $this->extension = new Extension();
+        $this->extension->setExtensionKey('foobar');
+        $this->extension->setVersion('1.0.0');
     }
 
     /**
      * @test
      */
-    public function addExtensionToQueueAddsExtensionToDownloadStorageArray()
+    public function addExtensionToQueueAddsExtensionToDownloadStorageArray(): void
     {
-        $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
-        $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
+        $this->downloadQueue->addExtensionToQueue($this->extension);
+        $extensionStorage = $this->downloadQueue->getExtensionQueue();
 
         self::assertArrayHasKey('foobar', $extensionStorage['download']);
     }
@@ -56,10 +57,10 @@ class DownloadQueueTest extends UnitTestCase
     /**
      * @test
      */
-    public function addExtensionToQueueAddsExtensionToUpdateStorageArray()
+    public function addExtensionToQueueAddsExtensionToUpdateStorageArray(): void
     {
-        $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'update');
-        $extensionStorage = $this->downloadQueueMock->_get('extensionStorage');
+        $this->downloadQueue->addExtensionToQueue($this->extension, 'update');
+        $extensionStorage = $this->downloadQueue->getExtensionQueue();
 
         self::assertArrayHasKey('foobar', $extensionStorage['update']);
     }
@@ -67,51 +68,44 @@ class DownloadQueueTest extends UnitTestCase
     /**
      * @test
      */
-    public function addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven()
+    public function addExtensionToQueueThrowsExceptionIfUnknownStackIsGiven(): void
     {
         $this->expectException(ExtensionManagerException::class);
         $this->expectExceptionCode(1342432103);
-        $this->downloadQueueMock->addExtensionToQueue($this->extensionMock, 'unknownStack');
+        $this->downloadQueue->addExtensionToQueue($this->extension, 'unknownStack');
     }
 
     /**
      * @test
      */
-    public function addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists()
+    public function addExtensionToQueueThrowsExceptionIfExtensionWithSameKeyAndDifferentValuesAlreadyExists(): void
     {
-        /** @var \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extensionMock2 */
-        $extensionMock2 = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class)
-            ->setMethods(['dummy'])
-            ->getMock();
-        $extensionMock2->setExtensionKey('foobar');
-        $extensionMock2->setVersion('1.0.3');
+        $extension = new Extension();
+        $extension->setExtensionKey('foobar');
+        $extension->setVersion('1.0.3');
 
         $this->expectException(ExtensionManagerException::class);
         $this->expectExceptionCode(1342432101);
-        $this->downloadQueueMock->addExtensionToQueue($extensionMock2);
-        $this->downloadQueueMock->addExtensionToQueue($this->extensionMock);
+        $this->downloadQueue->addExtensionToQueue($extension);
+        $this->downloadQueue->addExtensionToQueue($this->extension);
     }
 
     /**
      * @test
      */
-    public function removeExtensionFromQueueRemovesExtension()
+    public function removeExtensionFromQueueRemovesExtension(): void
     {
-        $extensionMock2 = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class, ['dummy']);
-        $extensionMock2->_set('extensionKey', 'foobarbaz');
-        $extensionMock2->_set('version', '1.0.3');
-        $this->downloadQueueMock->_set('extensionStorage', [
-            'download' => [
-                'foobar' => $this->extensionMock,
-                'foobarbaz' => $extensionMock2
-            ]
-        ]);
-        $extensionStorageBefore = $this->downloadQueueMock->_get('extensionStorage');
+        $extension = new Extension();
+        $extension->setExtensionKey('foobarbaz');
+        $extension->setVersion('1.0.3');
+        $this->downloadQueue->addExtensionToQueue($this->extension);
+        $this->downloadQueue->addExtensionToQueue($extension);
+        $extensionStorageBefore = $this->downloadQueue->getExtensionQueue();
 
         self::assertTrue(array_key_exists('foobar', $extensionStorageBefore['download']));
 
-        $this->downloadQueueMock->removeExtensionFromQueue($this->extensionMock);
-        $extensionStorageAfter = $this->downloadQueueMock->_get('extensionStorage');
+        $this->downloadQueue->removeExtensionFromQueue($this->extension);
+        $extensionStorageAfter = $this->downloadQueue->getExtensionQueue();
 
         self::assertFalse(array_key_exists('foobar', $extensionStorageAfter['download']));
     }
index ca401c6..e630c14 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 declare(strict_types = 1);
+
 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Report;
 
 /*
@@ -15,7 +16,10 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Report;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
 use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
 use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
 use TYPO3\CMS\Extensionmanager\Domain\Model\Repository;
@@ -52,18 +56,19 @@ class ExtensionStatusTest extends UnitTestCase
     protected function setUp(): void
     {
         parent::setUp();
-        $this->mockObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)->getMock();
+        $this->mockObjectManager = $this->getMockBuilder(ObjectManager::class)->disableOriginalConstructor()->getMock();
         /** @var $mockRepositoryRepository RepositoryRepository|\PHPUnit\Framework\MockObject\MockObject */
         $this->mockRepositoryRepository = $this->getMockBuilder(RepositoryRepository::class)
             ->setConstructorArgs([$this->mockObjectManager])
             ->getMock();
         $this->mockLanguageService = $this->createMock(LanguageService::class);
+        $this->resetSingletonInstances = true;
     }
 
     /**
      * @test
      */
-    public function extensionStatusImplementsStatusProviderInterface()
+    public function extensionStatusImplementsStatusProviderInterface(): void
     {
         $reportMock = $this->createMock(ExtensionStatus::class);
         self::assertInstanceOf(StatusProviderInterface::class, $reportMock);
@@ -72,10 +77,10 @@ class ExtensionStatusTest extends UnitTestCase
     /**
      * @test
      */
-    public function getStatusReturnsArray()
+    public function getStatusReturnsArray(): void
     {
         $report = $this->getMockBuilder(ExtensionStatus::class)
-            ->setMethods(['getSecurityStatusOfExtensions', 'getMainRepositoryStatus'])
+            ->onlyMethods(['getSecurityStatusOfExtensions', 'getMainRepositoryStatus'])
             ->disableOriginalConstructor()
             ->getMock();
         self::assertIsArray($report->getStatus());
@@ -84,31 +89,30 @@ class ExtensionStatusTest extends UnitTestCase
     /**
      * @test
      */
-    public function getStatusReturnArrayContainsFiveEntries()
+    public function getStatusReturnArrayContainsFiveEntries(): void
     {
         $report = $this->getMockBuilder(ExtensionStatus::class)
-            ->setMethods(['getSecurityStatusOfExtensions', 'getMainRepositoryStatus'])
+            ->onlyMethods(['getSecurityStatusOfExtensions', 'getMainRepositoryStatus'])
             ->disableOriginalConstructor()
             ->getMock();
-        self::assertSame(5, \count($report->getStatus()));
+        self::assertCount(5, $report->getStatus());
     }
 
     /**
      * @test
      */
-    public function getStatusReturnArrayContainsInstancesOfReportsStatusStatus()
+    public function getStatusReturnArrayContainsInstancesOfReportsStatusStatus(): void
     {
         $statusObject = $this->getMockBuilder(Status::class)
             ->setConstructorArgs(['title', 'value'])
             ->getMock();
-        /** @var ExtensionStatus $report */
         $report = $this->getMockBuilder(ExtensionStatus::class)
-            ->setMethods(['getSecurityStatusOfExtensions', 'getMainRepositoryStatus'])
+            ->onlyMethods(['getSecurityStatusOfExtensions', 'getMainRepositoryStatus'])
             ->disableOriginalConstructor()
             ->getMock();
-        $report->expects(self::any())->method('getMainRepositoryStatus')->willReturn($statusObject);
-        $resultStatuses = $report->getStatus();
-        foreach ($resultStatuses as $status) {
+        $report->method('getMainRepositoryStatus')->willReturn($statusObject);
+
+        foreach ($report->getStatus() as $status) {
             if ($status) {
                 self::assertInstanceOf(Status::class, $status);
             }
@@ -118,476 +122,155 @@ class ExtensionStatusTest extends UnitTestCase
     /**
      * @test
      */
-    public function getStatusCallsGetMainRepositoryStatusForMainRepositoryStatusResult()
+    public function getStatusCallsMainRepositoryForMainRepositoryStatusResult(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(0);
-        $mockExtensionList = [
-            'enetcache' => [
-                'installed' => true,
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
-
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['getMainRepositoryStatus'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-        $mockReport
-            ->expects(self::once())
-            ->method('getMainRepositoryStatus')
-            ->willReturn('foo');
+        [$repositoryRepositoryProphecy] = $this->setUpRepositoryStatusTests();
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
 
-        $result = $mockReport->getStatus();
-        self::assertSame('foo', $result['mainRepositoryStatus']);
+        $repositoryRepositoryProphecy->findOneTypo3OrgRepository()->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getMainRepositoryStatusReturnsErrorStatusIfRepositoryIsNotFound()
+    public function getStatusReturnsErrorStatusIfRepositoryIsNotFound(): void
     {
-        $this->mockRepositoryRepository
-            ->expects(self::once())
-            ->method('findOneTypo3OrgRepository')
-            ->willReturn(null);
-
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::once())
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::ERROR)
-            ->willReturn($statusMock);
-        $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getMainRepositoryStatus');
-        self::assertSame($statusMock, $result);
-    }
+        [$repositoryRepositoryProphecy, $objectManagerProphecy] = $this->setUpRepositoryStatusTests(0, true, false);
 
-    /**
-     * @test
-     */
-    public function getMainRepositoryStatusReturnsNoticeIfRepositoryUpdateIsLongerThanSevenDaysAgo()
-    {
-        /** @var $mockRepositoryRepository Repository|\PHPUnit\Framework\MockObject\MockObject */
-        $mockRepository = $this->getMockBuilder(Repository::class)->getMock();
-        $mockRepository
-            ->expects(self::once())
-            ->method('getLastUpdate')
-            ->willReturn(new \DateTime('-8 days'));
+        $repositoryRepositoryProphecy->findOneTypo3OrgRepository()->willReturn(null);
 
-        $this->mockRepositoryRepository
-            ->expects(self::once())
-            ->method('findOneTypo3OrgRepository')
-            ->willReturn($mockRepository);
-
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::once())
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::NOTICE)
-            ->willReturn($statusMock);
-        $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        /** @var $result Status */
-        $result = $mockReport->_call('getMainRepositoryStatus');
-        self::assertSame($statusMock, $result);
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
+
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::ERROR)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getMainRepositoryStatusReturnsOkIfUpdatedLessThanSevenDaysAgo()
+    public function getStatusReturnsNoticeIfRepositoryUpdateIsLongerThanSevenDaysAgo(): void
     {
-        /** @var $mockRepositoryRepository Repository|\PHPUnit\Framework\MockObject\MockObject */
-        $mockRepository = $this->getMockBuilder(Repository::class)->getMock();
-        $mockRepository
-            ->expects(self::once())
-            ->method('getLastUpdate')
-            ->willReturn(new \DateTime('-6 days'));
+        [$repositoryRepositoryProphecy, $objectManagerProphecy] = $this->setUpRepositoryStatusTests(0, true, false);
 
-        $this->mockRepositoryRepository
-            ->expects(self::once())
-            ->method('findOneTypo3OrgRepository')
-            ->willReturn($mockRepository);
-
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::once())
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::OK)
-            ->willReturn($statusMock);
-        $mockReport->_set('repositoryRepository', $this->mockRepositoryRepository);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        /** @var $result Status */
-        $result = $mockReport->_call('getMainRepositoryStatus');
-        self::assertSame($statusMock, $result);
+        $repository = new Repository();
+        $repository->setLastUpdate(new \DateTime('-14days'));
+        $repositoryRepositoryProphecy->findOneTypo3OrgRepository()->willReturn($repository);
+
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
+
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::NOTICE)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoInsecureExtensionIsLoaded()
+    public function getStatusReturnsOkIfUpdatedLessThanSevenDaysAgo(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(0);
-        $mockExtensionList = [
-            'enetcache' => [
-                'installed' => true,
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
+        [, $objectManagerProphecy] = $this->setUpRepositoryStatusTests();
+
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(0))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::OK)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->loaded;
-        self::assertSame($statusMock, $loadedResult);
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::OK)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfInsecureExtensionIsLoaded()
+    public function getStatusReturnsOkForLoadedExtensionIfNoInsecureExtensionIsLoaded(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(-1);
-        $mockExtensionList = [
-            'enetcache' => [
-                'installed' => true,
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
+        [, $objectManagerProphecy] = $this->setUpRepositoryStatusTests();
+
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(0))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::ERROR)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->loaded;
-        self::assertSame($statusMock, $loadedResult);
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::OK)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoInsecureExtensionExists()
+    public function getStatusReturnsErrorForLoadedExtensionIfInsecureExtensionIsLoaded(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(0);
-        $mockExtensionList = [
-            'enetcache' => [
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
+        [, $objectManagerProphecy] = $this->setUpRepositoryStatusTests(-1);
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(1))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::OK)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->existing;
-        self::assertSame($statusMock, $loadedResult);
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
+
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::ERROR)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfInsecureExtensionExists()
+    public function getStatusReturnsOkForExistingExtensionIfNoInsecureExtensionExists(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(-1);
-        $mockExtensionList = [
-            'enetcache' => [
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
+        [, $objectManagerProphecy] = $this->setUpRepositoryStatusTests(0, false);
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(1))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::WARNING)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->existing;
-        self::assertSame($statusMock, $loadedResult);
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
+
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::OK)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getSecurityStatusOfExtensionsReturnsOkForLoadedExtensionIfNoOutdatedExtensionIsLoaded()
+    public function getStatusReturnsWarningForExistingExtensionIfInsecureExtensionExistsButIsNotLoaded(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(0);
-        $mockExtensionList = [
-            'enetcache' => [
-                'installed' => true,
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
+        [, $objectManagerProphecy] = $this->setUpRepositoryStatusTests(-1, false);
+
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(2))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::OK)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->loadedoutdated;
-        self::assertSame($statusMock, $loadedResult);
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::WARNING)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getSecurityStatusOfExtensionsReturnsErrorForLoadedExtensionIfOutdatedExtensionIsLoaded()
+    public function getStatusReturnsWarningForLoadedExtensionIfOutdatedExtensionIsLoaded(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(-2);
-        $mockExtensionList = [
-            'enetcache' => [
-                'installed' => true,
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
+        [, $objectManagerProphecy] = $this->setUpRepositoryStatusTests(-2, true);
+
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(2))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::WARNING)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->loadedoutdated;
-        self::assertSame($statusMock, $loadedResult);
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::WARNING)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function getSecurityStatusOfExtensionsReturnsOkForExistingExtensionIfNoOutdatedExtensionExists()
+    public function getStatusReturnsErrorForExistingExtensionIfOutdatedExtensionExists(): void
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(0);
-        $mockExtensionList = [
-            'enetcache' => [
-                'terObject' => $mockTerObject
-            ],
-        ];
-        /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
-        $mockListUtility = $this->getMockBuilder(ListUtility::class)->getMock();
-        $mockListUtility
-            ->expects(self::once())
-            ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
-            ->willReturn($mockExtensionList);
+        [, $objectManagerProphecy] = $this->setUpRepositoryStatusTests(-2, false);
+
+        $extensionStatus = new ExtensionStatus();
+        $extensionStatus->getStatus();
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(3))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::OK)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->existingoutdated;
-        self::assertSame($statusMock, $loadedResult);
+        $objectManagerProphecy->get(Status::class, Argument::any(), Argument::any(), Argument::any(), Status::WARNING)->shouldHaveBeenCalled();
     }
 
     /**
-     * @test
+     * @param int $reviewState
+     * @param bool $installed
+     * @param bool $setupRepositoryStatusOk
+     * @return array
+     * @throws \TYPO3\CMS\Extbase\Object\Exception
      */
-    public function getSecurityStatusOfExtensionsReturnsErrorForExistingExtensionIfOutdatedExtensionExists()
+    protected function setUpRepositoryStatusTests(int $reviewState = 0, bool $installed = true, bool $setupRepositoryStatusOk = true): array
     {
-        /** @var $mockTerObject Extension|\PHPUnit\Framework\MockObject\MockObject */
-        $mockTerObject = $this->getMockBuilder(Extension::class)->getMock();
-        $mockTerObject
-            ->expects(self::any())
-            ->method('getVersion')
-            ->willReturn('1.0.6');
-        $mockTerObject
-            ->expects(self::atLeastOnce())
-            ->method('getReviewState')
-            ->willReturn(-2);
+        $mockTerObject = new Extension();
+        $mockTerObject->setVersion('1.0.6');
+        $mockTerObject->setReviewState($reviewState);
+
         $mockExtensionList = [
             'enetcache' => [
-                'terObject' => $mockTerObject
+                'installed' => $installed,
+                'terObject' => $mockTerObject,
             ],
         ];
         /** @var $mockListUtility ListUtility|\PHPUnit\Framework\MockObject\MockObject */
@@ -597,21 +280,18 @@ class ExtensionStatusTest extends UnitTestCase
             ->method('getAvailableAndInstalledExtensionsWithAdditionalInformation')
             ->willReturn($mockExtensionList);
 
-        /** @var $mockReport ExtensionStatus|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $mockReport = $this->getAccessibleMock(ExtensionStatus::class, ['dummy'], [], '', false);
-        $mockReport->_set('objectManager', $this->mockObjectManager);
-        $statusMock = $this->createMock(Status::class);
-        $this->mockObjectManager
-            ->expects(self::at(3))
-            ->method('get')
-            ->with(self::anything(), self::anything(), self::anything(), self::anything(), Status::WARNING)
-            ->willReturn($statusMock);
-        $mockReport->_set('listUtility', $mockListUtility);
-        $mockReport->_set('languageService', $this->mockLanguageService);
-
-        $result = $mockReport->_call('getSecurityStatusOfExtensions');
-        /** @var $loadedResult Status */
-        $loadedResult = $result->existingoutdated;
-        self::assertSame($statusMock, $loadedResult);
+        $repositoryRepositoryProphecy = $this->prophesize(RepositoryRepository::class);
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        $objectManagerProphecy->get(RepositoryRepository::class)->willReturn($repositoryRepositoryProphecy->reveal());
+        $objectManagerProphecy->get(ListUtility::class)->willReturn($mockListUtility);
+        $objectManagerProphecy->get(LanguageService::class)->willReturn($this->mockLanguageService);
+        $objectManagerProphecy->get(Status::class, Argument::cetera())->willReturn(new Status('test status', 'test status value'));
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
+        if ($setupRepositoryStatusOk) {
+            $repository = new Repository();
+            $repository->setLastUpdate(new \DateTime('-4days'));
+            $repositoryRepositoryProphecy->findOneTypo3OrgRepository()->willReturn($repository);
+        }
+        return [$repositoryRepositoryProphecy, $objectManagerProphecy];
     }
 }
index c71034c..8263cb9 100644 (file)
@@ -15,6 +15,10 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
 use TYPO3\CMS\Extensionmanager\Domain\Model\DownloadQueue;
 use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
 use TYPO3\CMS\Extensionmanager\Service\ExtensionManagementService;
@@ -29,267 +33,159 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class ExtensionManagementServiceTest extends UnitTestCase
 {
-    /**
-     * @test
-     */
-    public function resolveDependenciesCallsDownloadDependenciesIfDownloadKeyExistsInQueue()
+    protected $managementService;
+    protected $downloadUtilityProphecy;
+    protected $dependencyUtilityProphecy;
+    protected $installUtilityProphecy;
+    protected $downloadQueue;
+    protected $extensionModelUtilityProphecy;
+
+    public function setUp(): void
     {
-        $managementMock = $this->getAccessibleMock(
-            ExtensionManagementService::class,
-            ['downloadDependencies', 'uninstallDependenciesToBeUpdated', 'setInExtensionRepository', 'downloadMainExtension', 'isAutomaticInstallationEnabled']
-        );
-        $managementMock->expects(self::any())->method('downloadMainExtension')->willReturn([]);
-        $managementMock->expects(self::any())->method('isAutomaticInstallationEnabled')->willReturn([false]);
-        $extensionModelMock = $this->getAccessibleMock(Extension::class);
-        $extensionModelMock->_set('extensionKey', 'foobar');
-        $extensionModelMock->_set('version', '1.0.0');
-        $dependencyUtilityMock = $this->getAccessibleMock(DependencyUtility::class, ['checkDependencies']);
-        $dependencyUtilityMock->expects(self::atLeastOnce())->method('checkDependencies');
-        $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
-        $downloadQueueMock = $this->getAccessibleMock(DownloadQueue::class, ['isCopyQueueEmpty', 'isQueueEmpty', 'resetExtensionQueue', 'addExtensionToInstallQueue']);
-        $downloadQueueMock->expects(self::any())->method('isCopyQueueEmpty')->willReturn(true);
-        $downloadQueueMock->expects(self::at(1))->method('isQueueEmpty')->with('download')->willReturn(false);
-        $downloadQueueMock->expects(self::at(4))->method('isQueueEmpty')->with('download')->willReturn(true);
-        $downloadQueueMock->expects(self::at(5))->method('isQueueEmpty')->with('update')->willReturn(true);
-        $downloadQueueMock->expects(self::atLeastOnce())->method('resetExtensionQueue')->willReturn([
-            'download' => [
-                'foo' => $extensionModelMock
-            ]
-        ]);
-        $managementMock->_set('downloadQueue', $downloadQueueMock);
-        $managementMock->expects(self::once())->method('downloadDependencies')->with(['foo' => $extensionModelMock])->willReturn([]);
-        $managementMock->_call('installExtension', $extensionModelMock);
+        parent::setUp();
+        $this->resetSingletonInstances = true;
+        $this->managementService = new ExtensionManagementService();
+        $objectManager = $this->prophesize(ObjectManager::class);
+        $objectManager->get(Dispatcher::class)->willReturn($this->prophesize(Dispatcher::class)->reveal());
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManager->reveal());
+
+        $this->downloadUtilityProphecy = $this->prophesize(DownloadUtility::class);
+        $this->dependencyUtilityProphecy = $this->prophesize(DependencyUtility::class);
+        $this->installUtilityProphecy = $this->prophesize(InstallUtility::class);
+        $this->downloadQueue = new DownloadQueue();
+        $this->extensionModelUtilityProphecy = $this->prophesize(ExtensionModelUtility::class);
+
+        $this->managementService->injectDependencyUtility($this->dependencyUtilityProphecy->reveal());
+        $this->managementService->injectDownloadUtility($this->downloadUtilityProphecy->reveal());
+        $this->managementService->injectInstallUtility($this->installUtilityProphecy->reveal());
+        $this->managementService->injectDownloadQueue($this->downloadQueue);
+        $this->managementService->injectExtensionModelUtility($this->extensionModelUtilityProphecy->reveal());
     }
 
     /**
      * @test
      */
-    public function resolveDependenciesCallsUpdateAndDownloadDependenciesIfUpdateKeyExistsInQueue()
+    public function installDownloadsExtensionIfNecessary(): void
     {
-        $managementMock = $this->getAccessibleMock(
-            ExtensionManagementService::class,
-            ['downloadDependencies', 'uninstallDependenciesToBeUpdated', 'setInExtensionRepository', 'downloadMainExtension', 'isAutomaticInstallationEnabled']
-        );
-        $managementMock->expects(self::any())->method('downloadMainExtension')->willReturn([]);
-        $managementMock->expects(self::any())->method('isAutomaticInstallationEnabled')->willReturn(true);
-        $extensionModelMock = $this->getAccessibleMock(Extension::class);
-        $extensionModelMock->_set('extensionKey', 'foobar');
-        $extensionModelMock->_set('version', '1.0.0');
-        $dependencyUtilityMock = $this->getAccessibleMock(DependencyUtility::class, ['checkDependencies']);
-        $dependencyUtilityMock->expects(self::atLeastOnce())->method('checkDependencies');
-        $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
-        $downloadQueueMock = $this->getAccessibleMock(DownloadQueue::class, ['isCopyQueueEmpty', 'isQueueEmpty', 'resetExtensionQueue', 'addExtensionToInstallQueue']);
-        $downloadQueueMock->expects(self::any())->method('isCopyQueueEmpty')->willReturn(true);
-        $downloadQueueMock->expects(self::at(1))->method('isQueueEmpty')->with('download')->willReturn(false);
-        $downloadQueueMock->expects(self::at(4))->method('isQueueEmpty')->with('download')->willReturn(true);
-        $downloadQueueMock->expects(self::at(5))->method('isQueueEmpty')->with('update')->willReturn(true);
-        $downloadQueueMock->expects(self::atLeastOnce())->method('resetExtensionQueue')->willReturn([
-            'update' => [
-                'foo' => $extensionModelMock
-            ]
-        ]);
-        $managementMock->_set('downloadQueue', $downloadQueueMock);
-        $managementMock->expects(self::once())->method('downloadDependencies')->with(['foo' => $extensionModelMock])->willReturn([]);
-        $managementMock->expects(self::once())->method('uninstallDependenciesToBeUpdated')->with(['foo' => $extensionModelMock])->willReturn([]);
-        $managementMock->_call('installExtension', $extensionModelMock);
+        $extension = new Extension();
+        $extension->setExtensionKey('foobar');
+        $extension->setVersion('1.0.0');
+        // an extension with a uid means it needs to be downloaded
+        $extension->_setProperty('uid', 123);
+
+        $this->managementService->installExtension($extension);
+        $this->downloadUtilityProphecy->download($extension)->shouldHaveBeenCalled();
     }
 
     /**
      * @test
      */
-    public function downloadDependenciesCallsDownloadUtilityDownloadMethod()
+    public function installExtensionReturnsFalseIfDependenciesCannotBeResolved(): void
     {
-        $managementMock = $this->getAccessibleMock(ExtensionManagementService::class, [
-            'dummy'
-        ]);
-
-        $extensionModelMock = $this->getAccessibleMock(Extension::class, ['getExtensionKey']);
-        $extensionModelMock->_set('extensionKey', 'foobar');
-        $extensionModelMock->_set('version', '1.0.0');
+        $extension = new Extension();
+        $this->dependencyUtilityProphecy->setLocalExtensionStorage(Argument::any())->willReturn();
+        $this->dependencyUtilityProphecy->setSkipDependencyCheck(false)->willReturn();
+        $this->dependencyUtilityProphecy->checkDependencies($extension)->willReturn();
 
-        $dependencyUtilityMock = $this->getAccessibleMock(DependencyUtility::class);
-        $dependencyUtilityMock->expects(self::atLeastOnce())->method('checkDependencies');
-        $installUtilityMock = $this->getMockBuilder(InstallUtility::class)->getMock();
-        $installUtilityMock->expects(self::any())->method('enrichExtensionWithDetails')->willReturn([]);
-        $extensionModelUtilityMock = $this->getMockBuilder(ExtensionModelUtility::class)->getMock();
-        $extensionModelUtilityMock->expects(self::any())->method('mapExtensionArrayToModel')->willReturn($extensionModelMock);
-        $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
-        $managementMock->_set('installUtility', $installUtilityMock);
-        $managementMock->_set('extensionModelUtility', $extensionModelUtilityMock);
+        $this->dependencyUtilityProphecy->hasDependencyErrors()->willReturn(true);
 
-        $downloadQueue = [
-            $extensionModelMock
-        ];
-        $downloadQueueMock = $this->getAccessibleMock(DownloadQueue::class, ['removeExtensionFromQueue', 'addExtensionToInstallQueue']);
-        $downloadUtilityMock = $this->getAccessibleMock(DownloadUtility::class, ['download']);
-        $downloadUtilityMock->expects(self::once())->method('download')->with($extensionModelMock);
-        $managementMock->_set('downloadUtility', $downloadUtilityMock);
-        $managementMock->_set('downloadQueue', $downloadQueueMock);
-        $managementMock->_call('downloadDependencies', $downloadQueue);
+        $result = $this->managementService->installExtension($extension);
+        self::assertFalse($result);
     }
 
     /**
      * @test
      */
-    public function downloadDependenciesCallsRemoveExtensionFromQueue()
+    public function installExtensionWillReturnInstalledExtensions(): void
     {
-        $managementMock = $this->getAccessibleMock(ExtensionManagementService::class, [
-            'dummy'
-        ]);
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
 
-        /** @var Extension $extensionModelMock */
-        $extensionModelMock = $this->getMockBuilder(Extension::class)
-            ->setMethods(['getExtensionKey'])
-            ->getMock();
-        $extensionModelMock->setExtensionKey('foobar');
-        $extensionModelMock->setVersion('1.0.0');
-        $downloadQueue = [
-            $extensionModelMock
-        ];
-
-        $dependencyUtilityMock = $this->getAccessibleMock(DependencyUtility::class);
-        $dependencyUtilityMock->expects(self::atLeastOnce())->method('checkDependencies');
-        $installUtilityMock = $this->getMockBuilder(InstallUtility::class)->getMock();
-        $installUtilityMock->expects(self::any())->method('enrichExtensionWithDetails')->willReturn([]);
-        $extensionModelUtilityMock = $this->getMockBuilder(ExtensionModelUtility::class)->getMock();
-        $extensionModelUtilityMock->expects(self::any())->method('mapExtensionArrayToModel')->willReturn($extensionModelMock);
-        $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
-        $managementMock->_set('installUtility', $installUtilityMock);
-        $managementMock->_set('extensionModelUtility', $extensionModelUtilityMock);
-
-        $downloadQueueMock = $this->getAccessibleMock(DownloadQueue::class, ['removeExtensionFromQueue', 'addExtensionToInstallQueue']);
-        $downloadUtilityMock = $this->getAccessibleMock(DownloadUtility::class, ['download']);
-        $downloadQueueMock->expects(self::once())->method('removeExtensionFromQueue')->with($extensionModelMock);
-        $managementMock->_set('downloadUtility', $downloadUtilityMock);
-        $managementMock->_set('downloadQueue', $downloadQueueMock);
-        $managementMock->_call('downloadDependencies', $downloadQueue);
+        $result = $this->managementService->installExtension($extension);
+        self::assertSame(['installed' => ['foo' => 'foo']], $result);
     }
 
     /**
      * @test
      */
-    public function downloadDependenciesReturnsResolvedDependencies()
+    public function installExtensionWillReturnDownloadedExtensions(): void
     {
-        $managementMock = $this->getAccessibleMock(ExtensionManagementService::class, [
-            'dummy'
-        ]);
-
-        $extensionModelMock = $this->getAccessibleMock(Extension::class, ['getExtensionKey']);
-        $extensionModelMock->_set('extensionKey', 'foobar');
-        $extensionModelMock->_set('version', '1.0.0');
-        $downloadQueue = [
-            $extensionModelMock
-        ];
-
-        $dependencyUtilityMock = $this->getAccessibleMock(DependencyUtility::class);
-        $dependencyUtilityMock->expects(self::atLeastOnce())->method('checkDependencies');
-        $installUtilityMock = $this->getMockBuilder(InstallUtility::class)->getMock();
-        $installUtilityMock->expects(self::any())->method('enrichExtensionWithDetails')->willReturn([]);
-        $extensionModelUtilityMock = $this->getMockBuilder(ExtensionModelUtility::class)->getMock();
-        $extensionModelUtilityMock->expects(self::any())->method('mapExtensionArrayToModel')->willReturn($extensionModelMock);
-        $managementMock->_set('dependencyUtility', $dependencyUtilityMock);
-        $managementMock->_set('installUtility', $installUtilityMock);
-        $managementMock->_set('extensionModelUtility', $extensionModelUtilityMock);
-
-        $downloadQueueMock = $this->getAccessibleMock(DownloadQueue::class, ['removeExtensionFromQueue', 'addExtensionToInstallQueue']);
-        $downloadUtilityMock = $this->getAccessibleMock(DownloadUtility::class, ['download']);
-        $extensionModelMock->expects(self::atLeastOnce())->method('getExtensionKey')->willReturn('foobar');
-        $managementMock->_set('downloadUtility', $downloadUtilityMock);
-        $managementMock->_set('downloadQueue', $downloadQueueMock);
-        $resolvedDependencies = $managementMock->_call('downloadDependencies', $downloadQueue);
-        self::assertEquals(['downloaded' => ['foobar' => $extensionModelMock]], $resolvedDependencies);
+        $downloadQueue = new DownloadQueue();
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $downloadQueue->addExtensionToQueue($extension);
+        $this->managementService->injectDownloadQueue($downloadQueue);
+        $this->installUtilityProphecy->enrichExtensionWithDetails('foo')->willReturn([]);
+        $this->installUtilityProphecy->reloadAvailableExtensions()->willReturn();
+        $this->installUtilityProphecy->install('foo')->willReturn();
+        $this->extensionModelUtilityProphecy->mapExtensionArrayToModel([])->willReturn($extension);
+
+        $result = $this->managementService->installExtension($extension);
+        self::assertSame(['downloaded' => ['foo' => $extension], 'installed' => ['foo' => 'foo']], $result);
     }
 
     /**
      * @test
      */
-    public function uninstallDependenciesToBeUpdatedCallsUninstall()
+    public function installExtensionWillReturnUpdatedExtensions(): void
     {
-        $managementMock = $this->getAccessibleMock(ExtensionManagementService::class, [
-            'dummy'
-        ]);
-        $extensionModelMock = $this->getAccessibleMock(Extension::class, ['getExtensionKey']);
-        $extensionModelMock->_set('extensionKey', 'foobar');
-        $extensionModelMock->_set('version', '1.0.0');
-        $extensionModelMock->expects(self::atLeastOnce())->method('getExtensionKey')->willReturn('foobar');
-        $downloadQueue = [
-            $extensionModelMock
-        ];
-        $installUtility = $this->getAccessibleMock(InstallUtility::class, ['uninstall'], [], '', false);
-        $installUtility->expects(self::once())->method('uninstall')->with('foobar');
-        $managementMock->_set('installUtility', $installUtility);
-        $managementMock->_call('uninstallDependenciesToBeUpdated', $downloadQueue);
+        $downloadQueue = new DownloadQueue();
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $downloadQueue->addExtensionToQueue($extension, 'update');
+        $this->managementService->injectDownloadQueue($downloadQueue);
+        $this->installUtilityProphecy->enrichExtensionWithDetails('foo')->willReturn([]);
+        $this->installUtilityProphecy->reloadAvailableExtensions()->willReturn();
+        $this->extensionModelUtilityProphecy->mapExtensionArrayToModel([])->willReturn($extension);
+
+        // an extension update will uninstall the extension and install it again
+        $this->installUtilityProphecy->uninstall('foo')->shouldBeCalled();
+        $this->installUtilityProphecy->install('foo')->shouldBeCalled();
+
+        $result = $this->managementService->installExtension($extension);
+
+        self::assertSame(['updated' => ['foo' => $extension], 'installed' => ['foo' => 'foo']], $result);
     }
 
     /**
      * @test
      */
-    public function uninstallDependenciesToBeUpdatedReturnsResolvedDependencies()
+    public function markExtensionForCopyAddsExtensionToCopyQueue(): void
     {
-        $managementMock = $this->getAccessibleMock(ExtensionManagementService::class, [
-            'dummy'
-        ]);
-        $extensionModelMock = $this->getAccessibleMock(Extension::class, ['getExtensionKey']);
-        $extensionModelMock->_set('extensionKey', 'foobar');
-        $extensionModelMock->_set('version', '1.0.0');
-        $extensionModelMock->expects(self::atLeastOnce())->method('getExtensionKey')->willReturn('foobar');
-        $downloadQueue = [
-            $extensionModelMock
-        ];
-        $installUtility = $this->getAccessibleMock(InstallUtility::class, ['uninstall'], [], '', false);
-        $managementMock->_set('installUtility', $installUtility);
-        $resolvedDependencies = $managementMock->_call('uninstallDependenciesToBeUpdated', $downloadQueue);
-        self::assertEquals(['updated' => ['foobar' => $extensionModelMock]], $resolvedDependencies);
+        $this->managementService->markExtensionForCopy('ext', 'some/folder/');
+
+        self::assertSame(['ext' => 'some/folder/'], $this->downloadQueue->resetExtensionCopyStorage());
     }
 
     /**
      * @test
      */
-    public function installDependenciesCallsInstall()
+    public function markExtensionForDownloadAddsExtensionToDownloadQueueAndChecksDependencies(): void
     {
-        $managementMock = $this->getAccessibleMock(
-            ExtensionManagementService::class,
-            ['emitWillInstallExtensionsSignal', 'emitHasInstalledExtensionSignal']
-        );
-        /** @var Extension $extensionMock */
-        $extensionMock = $this->getMockBuilder(Extension::class)
-            ->setMethods(['dummy'])
-            ->getMock();
-        $extensionMock->setExtensionKey('foobar');
-        $installQueue = [
-            'foobar' => $extensionMock,
-        ];
-        $installUtility = $this->getAccessibleMock(InstallUtility::class, ['install', 'emitWillInstallExtensionsSignal'], [], '', false);
-        $installUtility->expects(self::once())->method('install')->with('foobar');
-        $managementMock->_set('installUtility', $installUtility);
-        $managementMock->_call('installDependencies', $installQueue);
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $this->dependencyUtilityProphecy->hasDependencyErrors()->willReturn(false);
+        $this->dependencyUtilityProphecy->checkDependencies($extension)->shouldBeCalled();
+
+        $this->managementService->markExtensionForDownload($extension);
+
+        $this->dependencyUtilityProphecy->checkDependencies($extension)->shouldHaveBeenCalled();
+        self::assertSame(['download' => ['foo' => $extension]], $this->downloadQueue->getExtensionQueue());
     }
 
     /**
      * @test
      */
-    public function installDependenciesReturnsResolvedDependencies()
+    public function markExtensionForUpdateAddsExtensionToUpdateQueueAndChecksDependencies(): void
     {
-        $managementMock = $this->getAccessibleMock(ExtensionManagementService::class, [
-            'emitWillInstallExtensionsSignal',
-            'emitHasInstalledExtensionSignal'
-        ]);
-        /** @var Extension $extensionMock */
-        $extensionMock = $this->getMockBuilder(Extension::class)
-            ->setMethods(['dummy'])
-            ->getMock();
-        $extensionMock->setExtensionKey('foobar');
-        $installQueue = [
-            'foobar' => $extensionMock,
-        ];
-        $installUtility = $this->getAccessibleMock(InstallUtility::class, ['install', 'emitWillInstallExtensionsSignal'], [], '', false);
-        $installUtility->expects(self::once())->method('install')->with('foobar');
-        $managementMock->_set('installUtility', $installUtility);
-        $resolvedDependencies = $managementMock->_call('installDependencies', $installQueue);
-        self::assertEquals([
-            'installed' => [
-                'foobar' => 'foobar'
-            ]
-        ], $resolvedDependencies);
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $this->dependencyUtilityProphecy->hasDependencyErrors()->willReturn(false);
+        $this->dependencyUtilityProphecy->checkDependencies($extension)->shouldBeCalled();
+
+        $this->managementService->markExtensionForUpdate($extension);
+
+        $this->dependencyUtilityProphecy->checkDependencies($extension)->shouldHaveBeenCalled();
+        self::assertSame(['update' => ['foo' => $extension]], $this->downloadQueue->getExtensionQueue());
     }
 }
index 0d2d72b..5ac285a 100644 (file)
@@ -43,302 +43,268 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function checkTypo3DependencyThrowsExceptionIfVersionNumberIsTooLow()
+    public function checkTypo3DependencyErrorsIfVersionNumberIsTooLow(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('15.0.0');
-        $dependencyMock->setIdentifier('typo3');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        $this->expectException(ExtensionManagerException::class);
-        $this->expectExceptionCode(1399144499);
-        $dependencyUtility->_call('checkTypo3Dependency', $dependencyMock);
-    }
-
-    /**
-     * @test
-     */
-    public function checkTypo3DependencyThrowsExceptionIfVersionNumberIsTooHigh()
-    {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('3.0.0');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $dependencyMock->setIdentifier('typo3');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
+        $dependency = new Dependency();
+        $dependency->setIdentifier('typo3');
+        $dependency->setLowestVersion('15.0.0');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
 
-        $this->expectException(ExtensionManagerException::class);
-        $this->expectExceptionCode(1399144521);
-        $dependencyUtility->_call('checkTypo3Dependency', $dependencyMock);
-    }
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
 
-    /**
-     * @test
-     */
-    public function checkTypo3DependencyThrowsExceptionIfIdentifierIsNotTypo3()
-    {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->setIdentifier('123');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
 
-        $this->expectException(ExtensionManagerException::class);
-        $this->expectExceptionCode(1399144551);
-        $dependencyUtility->_call('checkTypo3Dependency', $dependencyMock);
+        self::assertSame(1399144499, $errors['foo'][0]['code']);
     }
 
     /**
      * @test
      */
-    public function checkTypo3DependencyReturnsTrueIfVersionNumberIsInRange()
+    public function checkTypo3DependencyErrorsIfVersionNumberIsTooHigh(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('15.0.0');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $dependencyMock->setIdentifier('typo3');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        self::assertTrue($dependencyUtility->_call('checkTypo3Dependency', $dependencyMock));
+        $dependency = new Dependency();
+        $dependency->setHighestVersion('3.0.0');
+        $dependency->setLowestVersion('1.0.0');
+        $dependency->setIdentifier('typo3');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        self::assertSame(1399144521, $errors['foo'][0]['code']);
     }
 
     /**
      * @test
+     * @todo this can never happen with current code paths
      */
-    public function checkTypo3DependencyCanHandleEmptyVersionHighestVersion()
+    public function checkTypo3DependencyThrowsExceptionIfIdentifierIsNotTypo3(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $dependencyMock->setIdentifier('typo3');
+        $dependency = new Dependency();
+        $dependency->setIdentifier('123');
         $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
 
-        self::assertTrue($dependencyUtility->_call('checkTypo3Dependency', $dependencyMock));
+        $this->expectException(ExtensionManagerException::class);
+        $this->expectExceptionCode(1399144551);
+        $dependencyUtility->_call('checkTypo3Dependency', $dependency);
     }
 
     /**
      * @test
      */
-    public function checkTypo3DependencyCanHandleEmptyVersionLowestVersion()
+    public function checkTypo3DependencyReturnsTrueIfVersionNumberIsInRange(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('15.0.0');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('');
-        $dependencyMock->setIdentifier('typo3');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        self::assertTrue($dependencyUtility->_call('checkTypo3Dependency', $dependencyMock));
+        $dependency = new Dependency();
+        $dependency->setHighestVersion('15.0.0');
+        $dependency->setLowestVersion('1.0.0');
+        $dependency->setIdentifier('typo3');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        $dependency->setIdentifier('typo3');
+        self::assertCount(0, $errors);
     }
 
     /**
      * @test
      */
-    public function checkPhpDependencyThrowsExceptionIfVersionNumberIsTooLow()
+    public function checkTypo3DependencyCanHandleEmptyVersionHighestVersion(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('15.0.0');
-        $dependencyMock->setIdentifier('php');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        $this->expectException(ExtensionManagerException::class);
-        $this->expectExceptionCode(1377977857);
-        $dependencyUtility->_call('checkPhpDependency', $dependencyMock);
+        $dependency = new Dependency();
+        $dependency->setHighestVersion('');
+        $dependency->setLowestVersion('1.0.0');
+        $dependency->setIdentifier('typo3');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        $dependency->setIdentifier('typo3');
+        self::assertCount(0, $errors);
     }
 
     /**
      * @test
      */
-    public function checkPhpDependencyThrowsExceptionIfVersionNumberIsTooHigh()
+    public function checkTypo3DependencyCanHandleEmptyVersionLowestVersion(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('3.0.0');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $dependencyMock->setIdentifier('php');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        $this->expectException(ExtensionManagerException::class);
-        $this->expectExceptionCode(1377977856);
-        $dependencyUtility->_call('checkPhpDependency', $dependencyMock);
+        $dependency = new Dependency();
+        $dependency->setHighestVersion('15.0.0');
+        $dependency->setLowestVersion('');
+        $dependency->setIdentifier('typo3');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        $dependency->setIdentifier('typo3');
+        self::assertCount(0, $errors);
     }
 
     /**
      * @test
      */
-    public function checkPhpDependencyThrowsExceptionIfIdentifierIsNotTypo3()
+    public function checkPhpDependencyErrorsIfVersionNumberIsTooLow(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->setIdentifier('123');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
+        $dependency = new Dependency();
+        $dependency->setIdentifier('php');
+        $dependency->setLowestVersion('15.0.0');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
 
-        $this->expectException(ExtensionManagerException::class);
-        $this->expectExceptionCode(1377977858);
-        $dependencyUtility->_call('checkPhpDependency', $dependencyMock);
-    }
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
 
-    /**
-     * @test
-     */
-    public function checkPhpDependencyReturnsTrueIfVersionNumberIsInRange()
-    {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('15.0.0');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $dependencyMock->setIdentifier('php');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
 
-        self::assertTrue($dependencyUtility->_call('checkPhpDependency', $dependencyMock));
+        self::assertSame(1377977857, $errors['foo'][0]['code']);
     }
 
     /**
      * @test
      */
-    public function checkPhpDependencyCanHandleEmptyVersionHighestVersion()
+    public function checkPhpDependencyThrowsExceptionIfVersionNumberIsTooHigh(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $dependencyMock->setIdentifier('php');
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        self::assertTrue($dependencyUtility->_call('checkPhpDependency', $dependencyMock));
+        $dependency = new Dependency();
+        $dependency->setIdentifier('php');
+        $dependency->setHighestVersion('3.0.0');
+        $dependency->setLowestVersion('1.0.0');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        self::assertSame(1377977856, $errors['foo'][0]['code']);
     }
 
     /**
      * @test
+     * @todo there is no way for this to happen currently
      */
-    public function checkPhpDependencyCanHandleEmptyVersionLowestVersion()
+    public function checkPhpDependencyThrowsExceptionIfIdentifierIsNotPhp(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('15.0.0');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('');
-        $dependencyMock->setIdentifier('php');
+        $dependency = new Dependency();
+        $dependency->setIdentifier('123');
         $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
 
-        self::assertTrue($dependencyUtility->_call('checkPhpDependency', $dependencyMock));
-    }
-
-    /**
-     * @test
-     */
-    public function checkDependenciesCallsMethodToCheckPhpDependencies()
-    {
-        /** @var Extension $extensionMock */
-        $extensionMock = $this->getMockBuilder(Extension::class)
-            ->setMethods(['dummy'])
-            ->getMock();
-        /** @var Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->setIdentifier('php');
-        $dependencyStorage = new \SplObjectStorage();
-        $dependencyStorage->attach($dependencyMock);
-        $extensionMock->setDependencies($dependencyStorage);
-        /** @var \PHPUnit\Framework\MockObject\MockObject|DependencyUtility $dependencyUtility */
-        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)
-            ->setMethods(['checkPhpDependency', 'checkTypo3Dependency'])
-            ->getMock();
-        $dependencyUtility->expects(self::atLeastOnce())->method('checkPhpDependency');
-        $dependencyUtility->checkDependencies($extensionMock);
+        $this->expectException(ExtensionManagerException::class);
+        $this->expectExceptionCode(1377977858);
+        $dependencyUtility->_call('checkPhpDependency', $dependency);
     }
 
     /**
      * @test
      */
-    public function checkDependenciesCallsMethodToCheckTypo3Dependencies()
+    public function checkPhpDependencyReturnsTrueIfVersionNumberIsInRange(): void
     {
-        /** @var Extension $extensionMock */
-        $extensionMock = $this->getMockBuilder(Extension::class)
-            ->setMethods(['dummy'])
-            ->getMock();
-        /** @var Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->setIdentifier('typo3');
-        $dependencyStorage = new \SplObjectStorage();
-        $dependencyStorage->attach($dependencyMock);
-        $extensionMock->setDependencies($dependencyStorage);
-        /** @var \PHPUnit\Framework\MockObject\MockObject|DependencyUtility $dependencyUtility */
-        $dependencyUtility = $this->getMockBuilder(DependencyUtility::class)
-            ->setMethods(['checkPhpDependency', 'checkTypo3Dependency'])
-            ->getMock();
-
-        $dependencyUtility->expects(self::atLeastOnce())->method('checkTypo3Dependency');
-        $dependencyUtility->checkDependencies($extensionMock);
+        $dependency = new Dependency();
+        $dependency->setIdentifier('php');
+        $dependency->setHighestVersion('15.0.0');
+        $dependency->setLowestVersion('1.0.0');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        self::assertCount(0, $errors);
     }
 
     /**
      * @test
      */
-    public function isVersionCompatibleReturnsTrueForCompatibleVersion()
+    public function checkPhpDependencyCanHandleEmptyVersionHighestVersion(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('15.0.0');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $version = '3.3.3';
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        self::assertTrue($dependencyUtility->_call('isVersionCompatible', $version, $dependencyMock));
+        $dependency = new Dependency();
+        $dependency->setIdentifier('php');
+        $dependency->setHighestVersion('');
+        $dependency->setLowestVersion('1.0.0');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        self::assertCount(0, $errors);
     }
 
     /**
      * @test
      */
-    public function isVersionCompatibleReturnsFalseForIncompatibleVersion()
+    public function checkPhpDependencyCanHandleEmptyVersionLowestVersion(): void
     {
-        /** @var \PHPUnit\Framework\MockObject\MockObject|Dependency $dependencyMock */
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::atLeastOnce())->method('getHighestVersion')->willReturn('1.0.1');
-        $dependencyMock->expects(self::atLeastOnce())->method('getLowestVersion')->willReturn('1.0.0');
-        $version = '3.3.3';
-        $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-
-        self::assertFalse($dependencyUtility->_call('isVersionCompatible', $version, $dependencyMock));
+        $dependency = new Dependency();
+        $dependency->setIdentifier('php');
+        $dependency->setHighestVersion('15.0.0');
+        $dependency->setLowestVersion('');
+        $dependencies = new \SplObjectStorage();
+        $dependencies->attach($dependency);
+
+        $extension = new Extension();
+        $extension->setExtensionKey('foo');
+        $extension->setDependencies($dependencies);
+        $dependencyUtility = new DependencyUtility();
+
+        $dependencyUtility->checkDependencies($extension);
+        $errors = $dependencyUtility->getDependencyErrors();
+
+        self::assertCount(0, $errors);
     }
 
     /**
      * @test
      */
-    public function isDependentExtensionAvailableReturnsTrueIfExtensionIsAvailable()
+    public function isDependentExtensionAvailableReturnsTrueIfExtensionIsAvailable(): void
     {
         $availableExtensions = [
             'dummy' => [],
@@ -358,7 +324,7 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function isDependentExtensionAvailableReturnsFalseIfExtensionIsNotAvailable()
+    public function isDependentExtensionAvailableReturnsFalseIfExtensionIsNotAvailable(): void
     {
         $availableExtensions = [
             'dummy' => [],
@@ -378,7 +344,7 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function isAvailableVersionCompatibleCallsIsVersionCompatibleWithExtensionVersion()
+    public function isAvailableVersionCompatibleCallsIsVersionCompatibleWithExtensionVersion(): void
     {
         $emConfUtility = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Utility\EmConfUtility::class)
             ->setMethods(['includeEmConf'])
@@ -388,10 +354,8 @@ class DependencyUtilityTest extends UnitTestCase
             'version' => '1.0.0'
         ]);
         $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['setAvailableExtensions', 'isVersionCompatible']);
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getIdentifier'])
-            ->getMock();
-        $dependencyMock->expects(self::once())->method('getIdentifier')->willReturn('dummy');
+        $dependency = new Dependency();
+        $dependency->setIdentifier('dummy');
         $dependencyUtility->_set('emConfUtility', $emConfUtility);
         $dependencyUtility->_set('availableExtensions', [
             'dummy' => [
@@ -400,13 +364,13 @@ class DependencyUtilityTest extends UnitTestCase
         ]);
         $dependencyUtility->expects(self::once())->method('setAvailableExtensions');
         $dependencyUtility->expects(self::once())->method('isVersionCompatible')->with('1.0.0', self::anything());
-        $dependencyUtility->_call('isAvailableVersionCompatible', $dependencyMock);
+        $dependencyUtility->_call('isAvailableVersionCompatible', $dependency);
     }
 
     /**
      * @test
      */
-    public function isExtensionDownloadableFromTerReturnsTrueIfOneVersionExists()
+    public function isExtensionDownloadableFromTerReturnsTrueIfOneVersionExists(): void
     {
         $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
             ->setMethods(['countByExtensionKey'])
@@ -442,12 +406,10 @@ class DependencyUtilityTest extends UnitTestCase
      */
     public function isDownloadableVersionCompatibleReturnsTrueIfCompatibleVersionExists()
     {
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getIdentifier', 'getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::once())->method('getIdentifier')->willReturn('dummy');
-        $dependencyMock->expects(self::once())->method('getHighestVersion')->willReturn('10.0.0');
-        $dependencyMock->expects(self::once())->method('getLowestVersion')->willReturn('1.0.0');
+        $dependency = new Dependency();
+        $dependency->setIdentifier('dummy');
+        $dependency->setHighestVersion('10.0.0');
+        $dependency->setLowestVersion('1.0.0');
         $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
             ->setMethods(['countByVersionRangeAndExtensionKey'])
             ->setConstructorArgs([$this->objectManagerMock])
@@ -455,7 +417,7 @@ class DependencyUtilityTest extends UnitTestCase
         $extensionRepositoryMock->expects(self::once())->method('countByVersionRangeAndExtensionKey')->with('dummy', 1000000, 10000000)->willReturn(2);
         $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
         $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
-        $count = $dependencyUtility->_call('isDownloadableVersionCompatible', $dependencyMock);
+        $count = $dependencyUtility->_call('isDownloadableVersionCompatible', $dependency);
 
         self::assertTrue($count);
     }
@@ -463,12 +425,10 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function isDownloadableVersionCompatibleReturnsFalseIfIncompatibleVersionExists()
+    public function isDownloadableVersionCompatibleReturnsFalseIfIncompatibleVersionExists(): void
     {
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getIdentifier'])
-            ->getMock();
-        $dependencyMock->expects(self::once())->method('getIdentifier')->willReturn('dummy');
+        $dependency = new Dependency();
+        $dependency->setIdentifier('dummy');
         $extensionRepositoryMock = $this->getMockBuilder(ExtensionRepository::class)
             ->setMethods(['countByVersionRangeAndExtensionKey'])
             ->setConstructorArgs([$this->objectManagerMock])
@@ -480,7 +440,7 @@ class DependencyUtilityTest extends UnitTestCase
             'lowestIntegerVersion' => 1000000,
             'highestIntegerVersion' => 2000000
         ]);
-        $count = $dependencyUtility->_call('isDownloadableVersionCompatible', $dependencyMock);
+        $count = $dependencyUtility->_call('isDownloadableVersionCompatible', $dependency);
 
         self::assertFalse($count);
     }
@@ -488,20 +448,18 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function getLowestAndHighestIntegerVersionsReturnsArrayWithVersions()
+    public function getLowestAndHighestIntegerVersionsReturnsArrayWithVersions(): void
     {
         $expectedVersions = [
             'lowestIntegerVersion' => 1000000,
             'highestIntegerVersion' => 2000000
         ];
 
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getHighestVersion', 'getLowestVersion'])
-            ->getMock();
-        $dependencyMock->expects(self::once())->method('getHighestVersion')->willReturn('2.0.0');
-        $dependencyMock->expects(self::once())->method('getLowestVersion')->willReturn('1.0.0');
+        $dependency = new Dependency();
+        $dependency->setHighestVersion('2.0.0');
+        $dependency->setLowestVersion('1.0.0');
         $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['dummy']);
-        $versions = $dependencyUtility->_call('getLowestAndHighestIntegerVersions', $dependencyMock);
+        $versions = $dependencyUtility->_call('getLowestAndHighestIntegerVersions', $dependency);
 
         self::assertSame($expectedVersions, $versions);
     }
@@ -509,7 +467,7 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function getLatestCompatibleExtensionByIntegerVersionDependencyWillReturnExtensionModelOfLatestExtension()
+    public function getLatestCompatibleExtensionByIntegerVersionDependencyWillReturnExtensionModelOfLatestExtension(): void
     {
         $extension1 = new Extension();
         $extension1->setExtensionKey('foo');
@@ -521,10 +479,8 @@ class DependencyUtilityTest extends UnitTestCase
         $myStorage = new \TYPO3\CMS\Extensionmanager\Tests\Unit\Fixtures\LatestCompatibleExtensionObjectStorageFixture();
         $myStorage->extensions[] = $extension1;
         $myStorage->extensions[] = $extension2;
-        $dependencyMock = $this->getMockBuilder(Dependency::class)
-            ->setMethods(['getIdentifier'])
-            ->getMock();
-        $dependencyMock->expects(self::once())->method('getIdentifier')->willReturn('foobar');
+        $dependency = new Dependency();
+        $dependency->setIdentifier('foobar');
         $dependencyUtility = $this->getAccessibleMock(DependencyUtility::class, ['getLowestAndHighestIntegerVersions']);
         $dependencyUtility->expects(self::once())->method('getLowestAndHighestIntegerVersions')->willReturn([
             'lowestIntegerVersion' => 1000000,
@@ -536,7 +492,7 @@ class DependencyUtilityTest extends UnitTestCase
             ->getMock();
         $extensionRepositoryMock->expects(self::once())->method('findByVersionRangeAndExtensionKeyOrderedByVersion')->with('foobar', 1000000, 2000000)->willReturn($myStorage);
         $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
-        $extension = $dependencyUtility->_call('getLatestCompatibleExtensionByIntegerVersionDependency', $dependencyMock);
+        $extension = $dependencyUtility->_call('getLatestCompatibleExtensionByIntegerVersionDependency', $dependency);
 
         self::assertInstanceOf(Extension::class, $extension);
         self::assertSame('foo', $extension->getExtensionKey());
@@ -545,7 +501,7 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function filterYoungestVersionOfExtensionListFiltersAListToLatestVersion()
+    public function filterYoungestVersionOfExtensionListFiltersAListToLatestVersion(): void
     {
         // foo2 should be kept
         $foo1 = new Extension();
@@ -573,7 +529,7 @@ class DependencyUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function filterYoungestVersionOfExtensionListFiltersAListToLatestVersionWithOnlyCompatibleExtensions()
+    public function filterYoungestVersionOfExtensionListFiltersAListToLatestVersionWithOnlyCompatibleExtensions(): void
     {
         $suitableDependency = new Dependency();
         $suitableDependency->setIdentifier('typo3');
index b9273a2..154c261 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Extensionmanager\Domain\Model\Dependency;
+use TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -29,7 +31,7 @@ class ExtensionModelUtilityTest extends UnitTestCase
     /**
      * @test
      */
-    public function convertDependenciesToObjectsCreatesObjectStorage()
+    public function convertDependenciesToObjectsCreatesObjectStorage(): void
     {
         $serializedDependencies = serialize([
             'depends' => [
@@ -39,19 +41,18 @@ class ExtensionModelUtilityTest extends UnitTestCase
             ]
         ]);
         /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility */
-        $dependencyUtility = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility::class, ['dummy']);
+        $dependencyUtility = new ExtensionModelUtility();
         $objectManagerMock = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
-        $dependencyModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency::class, ['dummy']);
-        $objectManagerMock->expects(self::any())->method('get')->willReturn($dependencyModelMock);
-        $dependencyUtility->_set('objectManager', $objectManagerMock);
+        $objectManagerMock->method('get')->willReturn(new Dependency());
+        $dependencyUtility->injectObjectManager($objectManagerMock);
         $objectStorage = $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
-        self::assertTrue($objectStorage instanceof \SplObjectStorage);
+        self::assertInstanceOf(\SplObjectStorage::class, $objectStorage);
     }
 
     /**
      * @test
      */
-    public function convertDependenciesToObjectsSetsIdentifier()
+    public function convertDependenciesToObjectsSetsIdentifier(): void
     {
         $serializedDependencies = serialize([
             'depends' => [
@@ -60,22 +61,28 @@ class ExtensionModelUtilityTest extends UnitTestCase
                 'fn_lib' => ''
             ]
         ]);
-        /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility */
-        $dependencyUtility = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility::class, ['dummy']);
+
+        $dependencyUtility = new ExtensionModelUtility();
         $objectManagerMock = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
-        $dependencyModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency::class, ['setIdentifier']);
-        $objectManagerMock->expects(self::any())->method('get')->willReturn($dependencyModelMock);
-        $dependencyUtility->_set('objectManager', $objectManagerMock);
-        $dependencyModelMock->expects(self::at(0))->method('setIdentifier')->with('php');
-        $dependencyModelMock->expects(self::at(1))->method('setIdentifier')->with('typo3');
-        $dependencyModelMock->expects(self::at(2))->method('setIdentifier')->with('fn_lib');
-        $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
+        // ensure we get a new dependency on subsequent calls
+        $objectManagerMock->method('get')->willReturnCallback(
+            static function () {
+                return new Dependency();
+            }
+        );
+        $dependencyUtility->injectObjectManager($objectManagerMock);
+        $dependencyObjects = $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
+        $identifiers = [];
+        foreach ($dependencyObjects as $resultingDependency) {
+            $identifiers[] = $resultingDependency->getIdentifier();
+        }
+        self::assertSame($identifiers, ['php', 'typo3', 'fn_lib']);
     }
 
     /**
      * @return array
      */
-    public function convertDependenciesToObjectSetsVersionDataProvider()
+    public function convertDependenciesToObjectSetsVersionDataProvider(): array
     {
         return [
             'everything ok' => [
@@ -131,32 +138,35 @@ class ExtensionModelUtilityTest extends UnitTestCase
      * @param array $dependencies
      * @param array $returnValue
      */
-    public function convertDependenciesToObjectSetsVersion(array $dependencies, array $returnValue)
+    public function convertDependenciesToObjectSetsVersion(array $dependencies, array $returnValue): void
     {
         $serializedDependencies = serialize($dependencies);
-        /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility */
-        $dependencyUtility = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility::class, ['dummy']);
+        $dependencyUtility = new ExtensionModelUtility();
         $objectManagerMock = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
-        $dependencyModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency::class, ['setHighestVersion', 'setLowestVersion']);
-        $objectManagerMock->expects(self::any())->method('get')->willReturn($dependencyModelMock);
-        $dependencyUtility->_set('objectManager', $objectManagerMock);
-        $dependencyModelMock->expects(self::atLeastOnce())->method('setLowestVersion')->with(self::identicalTo($returnValue[0]));
-        $dependencyModelMock->expects(self::atLeastOnce())->method('setHighestVersion')->with(self::identicalTo($returnValue[1]));
-        $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
+        // ensure we get a new dependency on subsequent calls
+        $objectManagerMock->method('get')->willReturnCallback(
+            static function () {
+                return new Dependency();
+            }
+        );
+        $dependencyUtility->injectObjectManager($objectManagerMock);
+        $dependencyObjects = $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
+        foreach ($dependencyObjects as $resultingDependency) {
+            self::assertSame($returnValue[0], $resultingDependency->getLowestVersion());
+            self::assertSame($returnValue[1], $resultingDependency->getHighestVersion());
+        }
     }
 
     /**
      * @test
      */
-    public function convertDependenciesToObjectCanDealWithEmptyStringDependencyValues()
+    public function convertDependenciesToObjectCanDealWithEmptyStringDependencyValues(): void
     {
         $dependencies = [
             'depends' => ''
         ];
         $serializedDependencies = serialize($dependencies);
-        /** @var $dependencyUtility \TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility */
-        $dependencyUtility = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\ExtensionModelUtility::class, ['dummy']);
-        $dependencyObject = $dependencyUtility->convertDependenciesToObjects($serializedDependencies);
+        $dependencyObject = (new ExtensionModelUtility())->convertDependenciesToObjects($serializedDependencies);
         self::assertSame(0, $dependencyObject->count());
     }
 }
index 3c49dc8..514b665 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\ExtendsAbstractEntity;
 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
 
 /**
@@ -26,12 +27,12 @@ class AbstractFormViewHelperTest extends ViewHelperBaseTestcase
      */
     public function renderHiddenIdentityFieldReturnsAHiddenInputFieldContainingTheObjectsUID()
     {
-        $object = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\ExtendsAbstractEntity::class, ['dummy']);
-        $object->_set('uid', 123);
+        $extendsAbstractEntity = new ExtendsAbstractEntity();
+        $extendsAbstractEntity->_setProperty('uid', 123);
         $expectedResult = chr(10) . '<input type="hidden" name="prefix[theName][__identity]" value="123" />' . chr(10);
         $viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, ['prefixFieldName', 'registerFieldNameForFormTokenGeneration'], [], '', false);
         $viewHelper->expects(self::any())->method('prefixFieldName')->with('theName')->willReturn('prefix[theName]');
-        $actualResult = $viewHelper->_call('renderHiddenIdentityField', $object, 'theName');
+        $actualResult = $viewHelper->_call('renderHiddenIdentityField', $extendsAbstractEntity, 'theName');
         self::assertSame($expectedResult, $actualResult);
     }
 
@@ -40,13 +41,13 @@ class AbstractFormViewHelperTest extends ViewHelperBaseTestcase
      */
     public function renderHiddenIdentityFieldReturnsAHiddenInputFieldIfObjectIsNewButAClone()
     {
-        $object = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\ExtendsAbstractEntity::class, ['dummy']);
-        $object->_set('uid', 123);
-        $object = clone $object;
+        $extendsAbstractEntity = new ExtendsAbstractEntity();
+        $extendsAbstractEntity->_setProperty('uid', 123);
+        $object = clone $extendsAbstractEntity;
         $expectedResult = chr(10) . '<input type="hidden" name="prefix[theName][__identity]" value="123" />' . chr(10);
         $viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper::class, ['prefixFieldName', 'registerFieldNameForFormTokenGeneration'], [], '', false);
         $viewHelper->expects(self::any())->method('prefixFieldName')->with('theName')->willReturn('prefix[theName]');
-        $actualResult = $viewHelper->_call('renderHiddenIdentityField', $object, 'theName');
+        $actualResult = $viewHelper->_call('renderHiddenIdentityField', $extendsAbstractEntity, 'theName');
         self::assertSame($expectedResult, $actualResult);
     }
 
index 725edf5..672304a 100644 (file)
@@ -15,10 +15,13 @@ namespace TYPO3\CMS\Form\Tests\Unit\Domain\Configuration;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Form\Domain\Configuration\ConfigurationService;
 use TYPO3\CMS\Form\Domain\Configuration\Exception\PropertyException;
 use TYPO3\CMS\Form\Domain\Configuration\Exception\PrototypeNotFoundException;
 use TYPO3\CMS\Form\Domain\Configuration\FormDefinition\Validators\ValidationDto;
+use TYPO3\CMS\Form\Mvc\Configuration\ConfigurationManagerInterface;
 use TYPO3\CMS\Form\Service\TranslationService;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
@@ -27,80 +30,71 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class ConfigurationServiceTest extends UnitTestCase
 {
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->resetSingletonInstances = true;
+    }
 
     /**
      * @test
      */
-    public function getPrototypeConfigurationReturnsPrototypeConfiguration()
+    public function getPrototypeConfigurationReturnsPrototypeConfiguration(): void
     {
-        $mockConfigurationService = $this->getAccessibleMock(
-            ConfigurationService::class,
-            [
-                'dummy',
-            ],
-            [],
-            '',
-            false
-        );
-
-        $mockConfigurationService->_set(
-            'formSettings',
-            [
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        $configurationManager = $this->prophesize(ConfigurationManagerInterface::class);
+        $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_YAML_SETTINGS, 'form')
+            ->willReturn([
                 'prototypes' => [
                     'standard' => [
                         'key' => 'value',
                     ],
                 ],
-            ]
-        );
+            ]);
+        $objectManagerProphecy->get(ConfigurationManagerInterface::class)->willReturn($configurationManager->reveal());
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
+        $configurationService = new ConfigurationService();
+        $configurationService->initializeObject();
 
         $expected = [
             'key' => 'value',
         ];
 
-        self::assertSame($expected, $mockConfigurationService->getPrototypeConfiguration('standard'));
+        self::assertSame($expected, $configurationService->getPrototypeConfiguration('standard'));
     }
 
     /**
      * @test
      */
-    public function getPrototypeConfigurationThrowsExceptionIfNoPrototypeFound()
+    public function getPrototypeConfigurationThrowsExceptionIfNoPrototypeFound(): void
     {
-        $mockConfigurationService = $this->getAccessibleMock(
-            ConfigurationService::class,
-            [
-                'dummy',
-            ],
-            [],
-            '',
-            false
-        );
-
-        $this->expectException(PrototypeNotFoundException::class);
-        $this->expectExceptionCode(1475924277);
-
-        $mockConfigurationService->_set(
-            'formSettings',
-            [
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        $configurationManager = $this->prophesize(ConfigurationManagerInterface::class);
+        $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_YAML_SETTINGS, 'form')
+            ->willReturn([
                 'prototypes' => [
                     'noStandard' => [],
                 ],
-            ]
-        );
+            ]);
+        $objectManagerProphecy->get(ConfigurationManagerInterface::class)->willReturn($configurationManager->reveal());
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
+        $configurationService = new ConfigurationService();
 
-        $mockConfigurationService->getPrototypeConfiguration('standard');
+        $this->expectException(PrototypeNotFoundException::class);
+        $this->expectExceptionCode(1475924277);
+
+        $configurationService->getPrototypeConfiguration('standard');
     }
 
     /**
      * @test
      */
-    public function getSelectablePrototypeNamesDefinedInFormEditorSetupReturnsPrototypes()
+    public function getSelectablePrototypeNamesDefinedInFormEditorSetupReturnsPrototypes(): void
     {
-        $configurationService = $this->getAccessibleMock(ConfigurationService::class, ['dummy'], [], '', false);
-
-        $configurationService->_set(
-            'formSettings',
-            [
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        $configurationManager = $this->prophesize(ConfigurationManagerInterface::class);
+        $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_YAML_SETTINGS, 'form')
+            ->willReturn([
                 'formManager' => [
                     'selectablePrototypesConfiguration' => [
                         0 => [
@@ -114,8 +108,11 @@ class ConfigurationServiceTest extends UnitTestCase
                         ],
                     ],
                 ],
-            ]
-        );
+            ]);
+        $objectManagerProphecy->get(ConfigurationManagerInterface::class)->willReturn($configurationManager->reveal());
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
+        $configurationService = new ConfigurationService();
+        $configurationService->initializeObject();
 
         $expected = [
             'standard',
@@ -136,7 +133,7 @@ class ConfigurationServiceTest extends UnitTestCase
         array $configuration,
         ValidationDto $validationDto,
         bool $expectedReturn
-    ) {
+    ): void {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
             ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
@@ -165,7 +162,7 @@ class ConfigurationServiceTest extends UnitTestCase
         array $configuration,
         ValidationDto $validationDto,
         bool $expectedReturn
-    ) {
+    ): void {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
             ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
@@ -194,7 +191,7 @@ class ConfigurationServiceTest extends UnitTestCase
         array $configuration,
         ValidationDto $validationDto,
         bool $expectedReturn
-    ) {
+    ): void {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
             ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
@@ -223,7 +220,7 @@ class ConfigurationServiceTest extends UnitTestCase
         array $configuration,
         ValidationDto $validationDto,
         bool $expectedReturn
-    ) {
+    ): void {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
             ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
@@ -247,7 +244,7 @@ class ConfigurationServiceTest extends UnitTestCase
      * @test
      */
     public function getFormElementPredefinedDefaultValueFromFormEditorSetupThrowsExceptionIfNoPredefinedDefaultIsAvailable(
-    ) {
+    ): void {
         $this->expectException(PropertyException::class);
         $this->expectExceptionCode(1528578401);
 
@@ -258,7 +255,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method(
+        $configurationService->method(
             'isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup'
         )->willReturn(false);
         $validationDto = new ValidationDto(null, 'Text', null, 'properties.foo.1');
@@ -269,7 +266,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function getFormElementPredefinedDefaultValueFromFormEditorSetupReturnsDefaultValue()
+    public function getFormElementPredefinedDefaultValueFromFormEditorSetupReturnsDefaultValue(): void
     {
         $expected = 'foo';
         $configuration = ['formElements' => ['Text' => ['predefinedDefaults' => ['properties.foo.1' => $expected]]]];
@@ -284,7 +281,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method(
+        $configurationService->method(
             'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
         )->willReturn($configuration);
         $configurationService->expects(self::any())->method(
@@ -303,7 +300,7 @@ class ConfigurationServiceTest extends UnitTestCase
      * @test
      */
     public function getPropertyCollectionPredefinedDefaultValueFromFormEditorSetupThrowsExceptionIfNoPredefinedDefaultIsAvailable(
-    ) {
+    ): void {
         $this->expectException(PropertyException::class);
         $this->expectExceptionCode(1528578402);
 
@@ -314,7 +311,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method(
+        $configurationService->method(
             'isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup'
         )->willReturn(false);
         $validationDto = new ValidationDto(
@@ -332,7 +329,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function getPropertyCollectionPredefinedDefaultValueFromFormEditorSetupReturnsDefaultValue()
+    public function getPropertyCollectionPredefinedDefaultValueFromFormEditorSetupReturnsDefaultValue(): void
     {
         $expected = 'foo';
         $configuration = ['collections' => ['validators' => ['StringLength' => ['predefinedDefaults' => ['properties.foo.1' => $expected]]]]];
@@ -347,10 +344,10 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method(
+        $configurationService->method(
             'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
         )->willReturn($configuration);
-        $configurationService->expects(self::any())->method(
+        $configurationService->method(
             'isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup'
         )->willReturn(true);
 
@@ -380,7 +377,7 @@ class ConfigurationServiceTest extends UnitTestCase
         array $configuration,
         ValidationDto $validationDto,
         bool $expectedReturn
-    ) {
+    ): void {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
             ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
@@ -388,7 +385,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method(
+        $configurationService->method(
             'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
         )->willReturn($configuration);
 
@@ -409,7 +406,7 @@ class ConfigurationServiceTest extends UnitTestCase
         array $configuration,
         ValidationDto $validationDto,
         bool $expectedReturn
-    ) {
+    ): void {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
             ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
@@ -417,7 +414,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method(
+        $configurationService->method(
             'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
         )->willReturn($configuration);
 
@@ -430,7 +427,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function isFormElementTypeDefinedInFormSetup()
+    public function isFormElementTypeDefinedInFormSetup(): void
     {
         $configuration = [
             'formElementsDefinition' => [
@@ -445,7 +442,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method('getPrototypeConfiguration')->willReturn($configuration);
+        $configurationService->method('getPrototypeConfiguration')->willReturn($configuration);
 
         $validationDto = new ValidationDto('standard', 'Text');
         self::assertTrue($configurationService->isFormElementTypeDefinedInFormSetup($validationDto));
@@ -457,7 +454,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfHookResultIsNoFormDefinitionValidation()
+    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfHookResultIsNoFormDefinitionValidation(): void
     {
         $this->expectException(PropertyException::class);
         $this->expectExceptionCode(1528633966);
@@ -471,7 +468,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfPrototypeDoesNotMatch()
+    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfPrototypeDoesNotMatch(): void
     {
         $this->expectException(PropertyException::class);
         $this->expectExceptionCode(1528634966);
@@ -486,7 +483,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfFormElementTypeDoesNotMatch()
+    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfFormElementTypeDoesNotMatch(): void
     {
         $this->expectException(PropertyException::class);
         $this->expectExceptionCode(1528633967);
@@ -498,7 +495,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method('isFormElementTypeDefinedInFormSetup')->willReturn(false);
+        $configurationService->method('isFormElementTypeDefinedInFormSetup')->willReturn(false);
         $validationDto = new ValidationDto('standard', 'Text');
         $input = [$validationDto];
 
@@ -508,7 +505,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfPropertyCollectionNameIsInvalid()
+    public function addAdditionalPropertyPathsFromHookThrowsExceptionIfPropertyCollectionNameIsInvalid(): void
     {
         $this->expectException(PropertyException::class);
         $this->expectExceptionCode(1528636941);
@@ -520,7 +517,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method('isFormElementTypeDefinedInFormSetup')->willReturn(true);
+        $configurationService->method('isFormElementTypeDefinedInFormSetup')->willReturn(true);
         $validationDto = new ValidationDto('standard', 'Text', null, null, 'Bar', 'Baz');
         $input = [$validationDto];
 
@@ -530,7 +527,7 @@ class ConfigurationServiceTest extends UnitTestCase
     /**
      * @test
      */
-    public function addAdditionalPropertyPathsFromHookAddPaths()
+    public function addAdditionalPropertyPathsFromHookAddPaths(): void
     {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
@@ -539,7 +536,7 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $configurationService->expects(self::any())->method('isFormElementTypeDefinedInFormSetup')->willReturn(true);
+        $configurationService->method('isFormElementTypeDefinedInFormSetup')->willReturn(true);
 
         $input = [
             new ValidationDto('standard', 'Text', null, 'options.xxx', 'validators', 'Baz'),
@@ -592,7 +589,7 @@ class ConfigurationServiceTest extends UnitTestCase
      * @param array $configuration
      * @param array $expected
      */
-    public function buildFormDefinitionValidationConfigurationFromFormEditorSetup(array $configuration, array $expected)
+    public function buildFormDefinitionValidationConfigurationFromFormEditorSetup(array $configuration, array $expected): void
     {
         $configurationService = $this->getAccessibleMock(
             ConfigurationService::class,
@@ -615,15 +612,15 @@ class ConfigurationServiceTest extends UnitTestCase
             '',
             false
         );
-        $translationService->expects(self::any())->method('translateValuesRecursive')->willReturnArgument(0);
+        $translationService->method('translateValuesRecursive')->willReturnArgument(0);
 
-        $configurationService->expects(self::any())->method('getCacheEntry')->willReturn(null);
-        $configurationService->expects(self::any())->method('getPrototypeConfiguration')->willReturn($configuration);
-        $configurationService->expects(self::any())->method('getTranslationService')->willReturn($translationService);
-        $configurationService->expects(self::any())
+        $configurationService->method('getCacheEntry')->willReturn(null);
+        $configurationService->method('getPrototypeConfiguration')->willReturn($configuration);
+        $configurationService->method('getTranslationService')->willReturn($translationService);
+        $configurationService
             ->method('executeBuildFormDefinitionValidationConfigurationHooks')
             ->willReturnArgument(1);
-        $configurationService->expects(self::any())->method('setCacheEntry');
+        $configurationService->method('setCacheEntry');
 
         self::assertSame(
             $expected,
index 29980f5..10a8680 100644 (file)
@@ -149,7 +149,7 @@ class AbstractFormElementTest extends UnitTestCase
      */
     public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString(): void
     {
-        $mock = $this->getAccessibleMockForAbstractClass(
+        $mock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             ['is_in', 'a_type'],
             '',
@@ -167,7 +167,7 @@ class AbstractFormElementTest extends UnitTestCase
     public function initializeFormElementExpectedCallInitializeFormObjectHooks(): void
     {
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $abstractFormElementMock */
-        $abstractFormElementMock = $this->getAccessibleMockForAbstractClass(
+        $abstractFormElementMock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             [],
             '',
@@ -177,7 +177,7 @@ class AbstractFormElementTest extends UnitTestCase
             []
         );
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $secondMock */
-        $secondMock = $this->getAccessibleMockForAbstractClass(
+        $secondMock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             [],
             '',
@@ -209,7 +209,7 @@ class AbstractFormElementTest extends UnitTestCase
     public function getUniqueIdentifierExpectedUnique(): void
     {
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $abstractFormElementMock1 */
-        $abstractFormElementMock1 = $this->getAccessibleMockForAbstractClass(
+        $abstractFormElementMock1 = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             [],
             '',
@@ -222,7 +222,7 @@ class AbstractFormElementTest extends UnitTestCase
         );
 
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractFormElement $abstractFormElementMock2 */
-        $abstractFormElementMock2 = $this->getAccessibleMockForAbstractClass(
+        $abstractFormElementMock2 = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             [],
             '',
@@ -267,7 +267,7 @@ class AbstractFormElementTest extends UnitTestCase
             'dummy'
         ], [], '', false);
 
-        $abstractFormElementMock = $this->getAccessibleMockForAbstractClass(
+        $abstractFormElementMock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             ['is_in', 'a_type'],
             '',
@@ -298,7 +298,7 @@ class AbstractFormElementTest extends UnitTestCase
             'dummy'
         ], [], '', false);
 
-        $abstractFormElementMock = $this->getAccessibleMockForAbstractClass(
+        $abstractFormElementMock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             ['is_in', 'a_type'],
             '',
@@ -329,7 +329,7 @@ class AbstractFormElementTest extends UnitTestCase
             'dummy'
         ], [], '', false);
 
-        $abstractFormElementMock = $this->getAccessibleMockForAbstractClass(
+        $abstractFormElementMock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             ['is_in', 'a_type'],
             '',
@@ -383,7 +383,7 @@ class AbstractFormElementTest extends UnitTestCase
             'dummy'
         ], [], '', false);
 
-        $abstractFormElementMock = $this->getAccessibleMockForAbstractClass(
+        $abstractFormElementMock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
             ['is_in', 'a_type'],
             '',
index 32b088c..96a96fe 100644 (file)
@@ -37,7 +37,7 @@ class AbstractSectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructThrowsExceptionWhenIdentifierIsEmpty()
+    public function constructThrowsExceptionWhenIdentifierIsEmpty(): void
     {
         $this->expectException(IdentifierNotValidException::class);
         $this->expectExceptionCode(1477082501);
@@ -49,7 +49,7 @@ class AbstractSectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString()
+    public function constructMustNotThrowExceptionWhenIdentifierIsNonEmptyString(): void
     {
         $section = new Section('foobar', 'foobar');
         self::assertInstanceOf(AbstractSection::class, $section);
@@ -58,7 +58,7 @@ class AbstractSectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function createElementThrowsExceptionIfTypeDefinitionNotFoundAndSkipUnknownElementsIsFalse()
+    public function createElementThrowsExceptionIfTypeDefinitionNotFoundAndSkipUnknownElementsIsFalse(): void
     {
         /** @var \PHPUnit\Framework\MockObject\MockObject|FormDefinition $rootForm */
         $rootForm = $this->getMockBuilder(FormDefinition::class)
@@ -66,11 +66,9 @@ class AbstractSectionTest extends UnitTestCase
             ->disableOriginalConstructor()
             ->getMock();
         $rootForm
-            ->expects(self::any())
             ->method('getRenderingOptions')
             ->willReturn(['skipUnknownElements' => false]);
         $rootForm
-            ->expects(self::any())
             ->method('getTypeDefinitions')
             ->willReturn([]);
 
@@ -100,7 +98,7 @@ class AbstractSectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function createElementReturnsUnknownElementsIfTypeDefinitionIsNotFoundAndSkipUnknownElementsIsTrue()
+    public function createElementReturnsUnknownElementsIfTypeDefinitionIsNotFoundAndSkipUnknownElementsIsTrue(): void
     {
         /** @var \PHPUnit\Framework\MockObject\MockObject|FormDefinition $rootForm */
         $rootForm = $this->getMockBuilder(FormDefinition::class)
@@ -108,16 +106,14 @@ class AbstractSectionTest extends UnitTestCase
             ->disableOriginalConstructor()
             ->getMock();
         $rootForm
-            ->expects(self::any())
             ->method('getRenderingOptions')
             ->willReturn(['skipUnknownElements' => true]);
         $rootForm
-            ->expects(self::any())
             ->method('getTypeDefinitions')
             ->willReturn([]);
 
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractSection $mockAbstractSection */
-        $mockAbstractSection = $this->getAccessibleMockForAbstractClass(
+        $mockAbstractSection = $this->getMockForAbstractClass(
             AbstractSection::class,
             [],
             '',
@@ -131,7 +127,6 @@ class AbstractSectionTest extends UnitTestCase
 
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractSection $mockAbstractSection */
         $mockAbstractSection
-            ->expects(self::any())
             ->method('getRootForm')
             ->willReturn($rootForm);
 
@@ -149,7 +144,7 @@ class AbstractSectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function createElementThrowsExceptionIfTypeDefinitionIsNotSet()
+    public function createElementThrowsExceptionIfTypeDefinitionIsNotSet(): void
     {
         /** @var \PHPUnit\Framework\MockObject\MockObject|FormDefinition $rootForm */
         $rootForm = $this->getMockBuilder(FormDefinition::class)
@@ -157,16 +152,14 @@ class AbstractSectionTest extends UnitTestCase
             ->disableOriginalConstructor()
             ->getMock();
         $rootForm
-            ->expects(self::any())
             ->method('getRenderingOptions')
             ->willReturn(['skipUnknownElements' => true]);
         $rootForm
-            ->expects(self::any())
             ->method('getTypeDefinitions')
             ->willReturn(['foobar' => []]);
 
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractSection $mockAbstractSection */
-        $mockAbstractSection = $this->getAccessibleMockForAbstractClass(
+        $mockAbstractSection = $this->getMockForAbstractClass(
             AbstractSection::class,
             [],
             '',
@@ -179,7 +172,6 @@ class AbstractSectionTest extends UnitTestCase
         );
 
         $mockAbstractSection
-            ->expects(self::any())
             ->method('getRootForm')
             ->willReturn($rootForm);
 
@@ -192,11 +184,11 @@ class AbstractSectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function createElementThrowsExceptionIfTypeDefinitionNotInstanceOfFormElementInterface()
+    public function createElementThrowsExceptionIfTypeDefinitionNotInstanceOfFormElementInterface(): void
     {
         $this->resetSingletonInstances = true;
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractSection $mockAbstractSection */
-        $mockAbstractSection = $this->getAccessibleMockForAbstractClass(
+        $mockAbstractSection = $this->getMockForAbstractClass(
             AbstractSection::class,
             [],
             '',
@@ -214,11 +206,9 @@ class AbstractSectionTest extends UnitTestCase
             ->disableOriginalConstructor()
             ->getMock();
         $rootForm
-            ->expects(self::any())
             ->method('getRenderingOptions')
             ->willReturn([]);
         $rootForm
-            ->expects(self::any())
             ->method('getTypeDefinitions')
             ->willReturn(
                 [
@@ -229,7 +219,6 @@ class AbstractSectionTest extends UnitTestCase
             );
 
         $mockAbstractSection
-            ->expects(self::any())
             ->method('getRootForm')
             ->willReturn($rootForm);
 
@@ -245,7 +234,7 @@ class AbstractSectionTest extends UnitTestCase
     /**
      * @test
      */
-    public function createElementExpectedToAddAndInitializeElement()
+    public function createElementExpectedToAddAndInitializeElement(): void
     {
         $implementationMock = $this->getMockForAbstractClass(
             AbstractFormElement::class,
@@ -276,7 +265,7 @@ class AbstractSectionTest extends UnitTestCase
             ->with($typeDefinitionWithoutImplementationClassName);
 
         /** @var \PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractSection $mockAbstractSection */
-        $mockAbstractSection = $this->getAccessibleMockForAbstractClass(
+        $mockAbstractSection = $this->getMockForAbstractClass(
             AbstractSection::class,
             [],
             '',
@@ -294,16 +283,13 @@ class AbstractSectionTest extends UnitTestCase
             ->disableOriginalConstructor()
             ->getMock();
         $rootForm
-            ->expects(self::any())
             ->method('getRenderingOptions')
             ->willReturn([]);
         $rootForm
-            ->expects(self::any())
             ->method('getTypeDefinitions')
             ->willReturn(['foobar' => $typeDefinition]);
 
         $mockAbstractSection
-            ->expects(self::any())
             ->method('getRootForm')
             ->willReturn($rootForm);
 
index fa2f4a2..cce2f1b 100644 (file)
@@ -72,7 +72,7 @@ class RenderableVariantTest extends UnitTestCase
             'label' => 'some label',
             'properties' => $variantProperties
         ];
-        $mockVariant = $this->getAccessibleMock(RenderableVariant::class, ['getIdentifier'], [$variantIdentifier, $options, $mockFormElement], '', true);
+        $mockVariant = $this->getMockBuilder(RenderableVariant::class)->onlyMethods(['getIdentifier'])->setConstructorArgs([$variantIdentifier, $options, $mockFormElement])->getMock();
         $mockFormElement->addVariant($mockVariant);
         $mockFormElement->applyVariant($mockVariant);
 
index a34d121..8fa77d8 100644 (file)
@@ -36,47 +36,40 @@ class FormRuntimeTest extends UnitTestCase
     /**
      * @test
      */
-    public function renderThrowsExceptionIfFormDefinitionReturnsNoRendererClassName()
+    public function renderThrowsExceptionIfFormDefinitionReturnsNoRendererClassName(): void
     {
         $mockFormRuntime = $this->getAccessibleMock(FormRuntime::class, [
             'isAfterLastPage', 'processVariants'
         ], [], '', false);
 
-        $mockPage = $this->getAccessibleMock(Page::class, [
+        $mockPage = $this->getMockBuilder(Page::class)->onlyMethods([
             'getIndex'
-        ], [], '', false);
+        ])->disableOriginalConstructor()->getMock();
 
-        $mockFormState = $this->getAccessibleMock(FormState::class, [
-            'dummy'
-        ], [], '', false);
+        $mockFormState = $this->getMockBuilder(FormState::class)->disableOriginalConstructor()->getMock();
 
-        $mockFormDefinition = $this->getAccessibleMock(FormDefinition::class, [
+        $mockFormDefinition = $this->getMockBuilder(FormDefinition::class)->onlyMethods([
             'getRendererClassName',
             'getIdentifier'
-        ], [], '', false);
+        ])->disableOriginalConstructor()->getMock();
 
         $mockPage
-            ->expects(self::any())
             ->method('getIndex')
             ->willReturn(1);
 
         $mockFormDefinition
-            ->expects(self::any())
             ->method('getRendererClassName')
             ->willReturn('');
 
         $mockFormDefinition
-            ->expects(self::any())
             ->method('getIdentifier')
             ->willReturn('text-1');
 
         $mockFormRuntime
-            ->expects(self::any())
             ->method('isAfterLastPage')
             ->willReturn(false);
 
         $mockFormRuntime
-            ->expects(self::any())
             ->method('processVariants')
             ->willReturn(null);
 
@@ -93,7 +86,7 @@ class FormRuntimeTest extends UnitTestCase
     /**
      * @test
      */
-    public function renderThrowsExceptionIfRendererClassNameInstanceDoesNotImplementRendererInterface()
+    public function renderThrowsExceptionIfRendererClassNameInstanceDoesNotImplementRendererInterface(): void
     {
         $objectManagerProphecy = $this->prophesize(ObjectManager::class);
         GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
@@ -102,41 +95,34 @@ class FormRuntimeTest extends UnitTestCase
             'isAfterLastPage', 'processVariants'
         ], [], '', false);
 
-        $mockPage = $this->getAccessibleMock(Page::class, [
+        $mockPage = $this->getMockBuilder(Page::class)->onlyMethods([
             'getIndex'
-        ], [], '', false);
+        ])->disableOriginalConstructor()->getMock();
 
-        $mockFormState = $this->getAccessibleMock(FormState::class, [
-            'dummy'
-        ], [], '', false);
+        $mockFormState = $this->getMockBuilder(FormState::class)->disableOriginalConstructor()->getMock();
 
-        $mockFormDefinition = $this->getAccessibleMock(FormDefinition::class, [
+        $mockFormDefinition = $this->getMockBuilder(FormDefinition::class)->onlyMethods([
             'getRendererClassName',
             'getIdentifier'
-        ], [], '', false);
+        ])->disableOriginalConstructor()->getMock();
 
         $mockPage
-            ->expects(self::any())
             ->method('getIndex')
             ->willReturn(1);
 
         $mockFormDefinition
-            ->expects(self::any())
             ->method('getRendererClassName')
             ->willReturn('fooRenderer');
 
         $mockFormDefinition
-            ->expects(self::any())
             ->method('getIdentifier')
             ->willReturn('text-1');
 
         $mockFormRuntime
-            ->expects(self::any())
             ->method('isAfterLastPage')
             ->willReturn(false);
 
         $mockFormRuntime
-            ->expects(self::any())
             ->method('processVariants')
             ->willReturn(null);
 
index 155ce43..b97306a 100644 (file)
@@ -33,18 +33,23 @@ class ProcessingRuleTest extends UnitTestCase
      */
     protected $resetSingletonInstances = true;
 
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
+        $objectManagerProphecy->get(Result::class)->willReturn(new Result());
+        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
+    }
+
     /**
      * @test
      */
-    public function addValidatorAddValidator()
+    public function addValidatorAddsValidator(): void
     {
-        $mockProcessingRule = $this->getAccessibleMock(ProcessingRule::class, [
-            'dummy'
-        ], [], '', false);
-
-        $mockProcessingRule->_set('validator', new ConjunctionValidator([]));
+        $mockProcessingRule = new ProcessingRule();
+        $mockProcessingRule->injectConjunctionValidator(new ConjunctionValidator([]));
         $mockProcessingRule->addValidator(new TestValidator());
-        $validators = $mockProcessingRule->_get('validator')->getValidators();
+        $validators = $mockProcessingRule->getValidators();
         $validators->rewind();
         self::assertInstanceOf(AbstractValidator::class, $validators->current());
     }
@@ -52,51 +57,27 @@ class ProcessingRuleTest extends UnitTestCase
     /**
      * @test
      */
-    public function processNoPropertyMappingReturnsNotModifiedValue()
+    public function processNoPropertyMappingReturnsNotModifiedValue(): void
     {
-        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
-        $resultProphecy = $this->prophesize(Result::class);
-
-        $objectManagerProphecy
-            ->get(Result::class)
-            ->willReturn($resultProphecy->reveal());
-
-        $mockProcessingRule = $this->getAccessibleMock(ProcessingRule::class, [
-            'dummy'
-        ], [], '', false);
-
-        $mockProcessingRule->_set('dataType', null);
-        $mockProcessingRule->_set('processingMessages', $resultProphecy->reveal());
-        $mockProcessingRule->_set('validator', new ConjunctionValidator([]));
+        $processingRule = new ProcessingRule();
+        $processingRule->injectConjunctionValidator(new ConjunctionValidator([]));
 
         $input = 'someValue';
-        self::assertSame($input, $mockProcessingRule->_call('process', $input));
+        self::assertSame($input, $processingRule->process($input));
     }
 
     /**
      * @test
      */
-    public function processNoPropertyMappingAndHasErrorsIfValidatorContainsErrors()
+    public function processNoPropertyMappingAndHasErrorsIfValidatorContainsErrors(): void
     {
-        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
-        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
-
-        $objectManagerProphecy
-            ->get(Result::class)
-            ->willReturn(new Result);
-
-        $mockProcessingRule = $this->getAccessibleMock(ProcessingRule::class, [
-            'dummy'
-        ], [], '', true);
-
-        $mockProcessingRule->_set('dataType', null);
-        $mockProcessingRule->_set('validator', new ConjunctionValidator([]));
-        $mockProcessingRule->addValidator(new TestValidator());
+        $processingRule = new ProcessingRule();
+        $processingRule->injectConjunctionValidator(new ConjunctionValidator([]));
+        $processingRule->addValidator(new TestValidator());
 
         $input = 'addError';
-        $mockProcessingRule->_call('process', $input);
+        $processingRule->process($input);
 
-        self::assertTrue($mockProcessingRule->_get('processingMessages')->hasErrors());
+        self::assertTrue($processingRule->getProcessingMessages()->hasErrors());
     }
 }
index 6c01618..dafc801 100644 (file)
@@ -51,13 +51,10 @@ class AbstractTypolinkBuilderTest extends UnitTestCase
     {
         parent::setUp();
         $this->createMockedLoggerAndLogManager();
-        $this->frontendControllerMock = $this->getAccessibleMock(
-            TypoScriptFrontendController::class,
-            ['dummy'],
-            [],
-            '',
-            false
-        );
+        $this->frontendControllerMock = $this
+            ->getMockBuilder(TypoScriptFrontendController::class)
+            ->disableOriginalConstructor()
+            ->getMock();
     }
 
     //////////////////////
index dcf25bb..54acc1e 100644 (file)
@@ -32,45 +32,38 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function constructorThrowsExceptionIfParentIsNull()
+    public function constructorThrowsExceptionIfParentIsNull(): void
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionCode(1366222203);
-        /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
-        $node = $this->getAccessibleMock(DirectoryNode::class, ['dummy'], [], '', false);
-        $node->__construct([], null);
+        new DirectoryNode([], null);
     }
 
     /**
      * @test
      */
-    public function constructorThrowsExceptionIfNameContainsForwardSlash()
+    public function constructorThrowsExceptionIfNameContainsForwardSlash(): void
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionCode(1366226639);
         $parent = $this->createMock(NodeInterface::class);
-        /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
-        $node = $this->getAccessibleMock(DirectoryNode::class, ['dummy'], [], '', false);
         $structure = [
             'name' => 'foo/bar',
         ];
-        $node->__construct($structure, $parent);
+        new DirectoryNode($structure, $parent);
     }
 
     /**
      * @test
      */
-    public function constructorCallsCreateChildrenIfChildrenAreSet()
+    public function constructorCallsCreateChildrenIfChildrenAreSet(): void
     {
         $parent = $this->createMock(NodeInterface::class);
-        /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
-        $node = $this->getAccessibleMock(
-            DirectoryNode::class,
-            ['createChildren'],
-            [],
-            '',
-            false
-        );
+        /** @var $node DirectoryNode|\PHPUnit\Framework\MockObject\MockObject */
+        $node = $this->getMockBuilder(DirectoryNode::class)
+            ->setMethods(['createChildren'])
+            ->disableOriginalConstructor()
+            ->getMock();
         $childArray = [
             'foo',
         ];
@@ -85,7 +78,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function constructorSetsParent()
+    public function constructorSetsParent(): void
     {
         $parent = $this->createMock(NodeInterface::class);
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
@@ -100,7 +93,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function constructorSetsTargetPermission()
+    public function constructorSetsTargetPermission(): void
     {
         $parent = $this->createMock(NodeInterface::class);
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
@@ -117,20 +110,18 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function constructorSetsName()
+    public function constructorSetsName(): void
     {
-        /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
-        $node = $this->getAccessibleMock(DirectoryNode::class, ['dummy'], [], '', false);
         $parent = $this->createMock(RootNodeInterface::class);
         $name = $this->getUniqueId('test_');
-        $node->__construct(['name' => $name], $parent);
+        $node = new DirectoryNode(['name' => $name], $parent);
         self::assertSame($name, $node->getName());
     }
 
     /**
      * @test
      */
-    public function getStatusReturnsArray()
+    public function getStatusReturnsArray(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -141,19 +132,19 @@ class DirectoryNodeTest extends FolderStructureTestCase
             false
         );
         $path = $this->getVirtualTestDir('dir_');
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(true);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(true);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('exists')->willReturn(true);
+        $node->method('isDirectory')->willReturn(true);
+        $node->method('isPermissionCorrect')->willReturn(true);
+        $node->method('isWritable')->willReturn(true);
         self::assertIsArray($node->getStatus());
     }
 
     /**
      * @test
      */
-    public function getStatusReturnsArrayWithWarningStatusIfDirectoryNotExists()
+    public function getStatusReturnsArrayWithWarningStatusIfDirectoryNotExists(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -164,12 +155,12 @@ class DirectoryNodeTest extends FolderStructureTestCase
             false
         );
         $path = $this->getVirtualTestDir('dir_');
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
-        $node->expects(self::any())->method('exists')->willReturn(false);
-        $node->expects(self::any())->method('isDirectory')->willReturn(false);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(false);
-        $node->expects(self::any())->method('isWritable')->willReturn(false);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('exists')->willReturn(false);
+        $node->method('isDirectory')->willReturn(false);
+        $node->method('isPermissionCorrect')->willReturn(false);
+        $node->method('isWritable')->willReturn(false);
         $statusArray = $node->getStatus();
         self::assertSame(FlashMessage::WARNING, $statusArray[0]->getSeverity());
     }
@@ -177,7 +168,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function getStatusReturnsArrayWithErrorStatusIfNodeIsNotADirectory()
+    public function getStatusReturnsArrayWithErrorStatusIfNodeIsNotADirectory(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -189,12 +180,12 @@ class DirectoryNodeTest extends FolderStructureTestCase
         );
         $path = $this->getVirtualTestFilePath('dir_');
         touch($path);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(false);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(true);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('exists')->willReturn(true);
+        $node->method('isDirectory')->willReturn(false);
+        $node->method('isPermissionCorrect')->willReturn(true);
+        $node->method('isWritable')->willReturn(true);
         $statusArray = $node->getStatus();
         self::assertSame(FlashMessage::ERROR, $statusArray[0]->getSeverity());
     }
@@ -202,7 +193,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function getStatusReturnsArrayWithErrorStatusIfDirectoryExistsButIsNotWritable()
+    public function getStatusReturnsArrayWithErrorStatusIfDirectoryExistsButIsNotWritable(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -214,12 +205,12 @@ class DirectoryNodeTest extends FolderStructureTestCase
         );
         $path = $this->getVirtualTestFilePath('dir_');
         touch($path);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(true);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(false);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('exists')->willReturn(true);
+        $node->method('isDirectory')->willReturn(true);
+        $node->method('isPermissionCorrect')->willReturn(true);
+        $node->method('isWritable')->willReturn(false);
         $statusArray = $node->getStatus();
         self::assertSame(FlashMessage::ERROR, $statusArray[0]->getSeverity());
     }
@@ -227,7 +218,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function getStatusReturnsArrayWithNoticeStatusIfDirectoryExistsButPermissionAreNotCorrect()
+    public function getStatusReturnsArrayWithNoticeStatusIfDirectoryExistsButPermissionAreNotCorrect(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -239,12 +230,12 @@ class DirectoryNodeTest extends FolderStructureTestCase
         );
         $path = $this->getVirtualTestFilePath('dir_');
         touch($path);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(true);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(false);
-        $node->expects(self::any())->method('isWritable')->willReturn(true);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('exists')->willReturn(true);
+        $node->method('isDirectory')->willReturn(true);
+        $node->method('isPermissionCorrect')->willReturn(false);
+        $node->method('isWritable')->willReturn(true);
         $statusArray = $node->getStatus();
         self::assertSame(FlashMessage::NOTICE, $statusArray[0]->getSeverity());
     }
@@ -252,7 +243,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function getStatusReturnsArrayWithOkStatusIfDirectoryExistsAndPermissionAreCorrect()
+    public function getStatusReturnsArrayWithOkStatusIfDirectoryExistsAndPermissionAreCorrect(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -264,12 +255,12 @@ class DirectoryNodeTest extends FolderStructureTestCase
         );
         $path = $this->getVirtualTestFilePath('dir_');
         touch($path);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(true);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(true);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('exists')->willReturn(true);
+        $node->method('isDirectory')->willReturn(true);
+        $node->method('isPermissionCorrect')->willReturn(true);
+        $node->method('isWritable')->willReturn(true);
         $statusArray = $node->getStatus();
         self::assertSame(FlashMessage::OK, $statusArray[0]->getSeverity());
     }
@@ -277,7 +268,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function getStatusCallsGetStatusOnChildren()
+    public function getStatusCallsGetStatusOnChildren(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -287,10 +278,10 @@ class DirectoryNodeTest extends FolderStructureTestCase
             '',
             false
         );
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(true);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(true);
+        $node->method('exists')->willReturn(true);
+        $node->method('isDirectory')->willReturn(true);
+        $node->method('isPermissionCorrect')->willReturn(true);
+        $node->method('isWritable')->willReturn(true);
         $childMock1 = $this->createMock(NodeInterface::class);
         $childMock1->expects(self::once())->method('getStatus')->willReturn([]);
         $childMock2 = $this->createMock(NodeInterface::class);
@@ -302,7 +293,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function getStatusReturnsArrayWithOwnStatusAndStatusOfChild()
+    public function getStatusReturnsArrayWithOwnStatusAndStatusOfChild(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -312,10 +303,10 @@ class DirectoryNodeTest extends FolderStructureTestCase
             '',
             false
         );
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(true);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(true);
+        $node->method('exists')->willReturn(true);
+        $node->method('isDirectory')->willReturn(true);
+        $node->method('isPermissionCorrect')->willReturn(true);
+        $node->method('isWritable')->willReturn(true);
         $childMock = $this->createMock(NodeInterface::class);
         $childMessage = new FlashMessage('foo');
         $childMock->expects(self::once())->method('getStatus')->willReturn([$childMessage]);
@@ -330,16 +321,13 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function fixCallsFixSelfAndReturnsItsResult()
+    public function fixCallsFixSelfAndReturnsItsResult(): void
     {
-        /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
-        $node = $this->getAccessibleMock(
-            DirectoryNode::class,
-            ['fixSelf'],
-            [],
-            '',
-            false
-        );
+        /** @var $node DirectoryNode|\PHPUnit\Framework\MockObject\MockObject */
+        $node = $this->getMockBuilder(DirectoryNode::class)
+            ->disableOriginalConstructor()
+            ->setMethods(['fixSelf'])
+            ->getMock();
         $uniqueReturn = [$this->getUniqueId('foo_')];
         $node->expects(self::once())->method('fixSelf')->willReturn($uniqueReturn);
         self::assertSame($uniqueReturn, $node->fix());
@@ -348,7 +336,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function fixCallsFixOnChildrenAndReturnsMergedResult()
+    public function fixCallsFixOnChildrenAndReturnsMergedResult(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['fixSelf'], [], '', false);
@@ -371,7 +359,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function fixSelfCallsCreateDirectoryIfDirectoryDoesNotExistAndReturnsResult()
+    public function fixSelfCallsCreateDirectoryIfDirectoryDoesNotExistAndReturnsResult(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -382,7 +370,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
             false
         );
         $node->expects(self::once())->method('exists')->willReturn(false);
-        $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
+        $node->method('isPermissionCorrect')->willReturn(true);
         $uniqueReturn = new FlashMessage('foo');
         $node->expects(self::once())->method('createDirectory')->willReturn($uniqueReturn);
         self::assertSame([$uniqueReturn], $node->_call('fixSelf'));
@@ -391,7 +379,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function fixSelfReturnsErrorStatusIfNodeExistsButIsNotADirectoryAndReturnsResult()
+    public function fixSelfReturnsErrorStatusIfNodeExistsButIsNotADirectoryAndReturnsResult(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -401,11 +389,11 @@ class DirectoryNodeTest extends FolderStructureTestCase
             '',
             false
         );
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(true);
-        $node->expects(self::any())->method('isDirectory')->willReturn(false);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn('');
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn('');
+        $node->method('exists')->willReturn(true);
+        $node->method('isWritable')->willReturn(true);
+        $node->method('isDirectory')->willReturn(false);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn('');
+        $node->method('getAbsolutePath')->willReturn('');
         $result = $node->_call('fixSelf');
         self::assertSame(FlashMessage::ERROR, $result[0]->getSeverity());
     }
@@ -413,7 +401,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function fixSelfCallsFixPermissionIfDirectoryExistsButIsNotWritable()
+    public function fixSelfCallsFixPermissionIfDirectoryExistsButIsNotWritable(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(
@@ -423,8 +411,8 @@ class DirectoryNodeTest extends FolderStructureTestCase
             '',
             false
         );
-        $node->expects(self::any())->method('exists')->willReturn(true);
-        $node->expects(self::any())->method('isWritable')->willReturn(false);
+        $node->method('exists')->willReturn(true);
+        $node->method('isWritable')->willReturn(false);
         $message = new FlashMessage('foo');
         $node->expects(self::once())->method('fixPermission')->willReturn($message);
         self::assertSame([$message], $node->_call('fixSelf'));
@@ -433,7 +421,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function createDirectoryThrowsExceptionIfNodeExists()
+    public function createDirectoryThrowsExceptionIfNodeExists(): void
     {
         $this->expectException(Exception::class);
         $this->expectExceptionCode(1366740091);
@@ -447,36 +435,36 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function createDirectoryCreatesDirectory()
+    public function createDirectoryCreatesDirectory(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
         $path = $this->getVirtualTestFilePath('dir_');
         $node->expects(self::once())->method('exists')->willReturn(false);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
         $node->_call('createDirectory');
-        self::assertTrue(is_dir($path));
+        self::assertDirectoryExists($path);
     }
 
     /**
      * @test
      */
-    public function createDirectoryReturnsOkStatusIfDirectoryWasCreated()
+    public function createDirectoryReturnsOkStatusIfDirectoryWasCreated(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
         $path = $this->getVirtualTestFilePath('dir_');
         $node->expects(self::once())->method('exists')->willReturn(false);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
+        $node->method('getAbsolutePath')->willReturn($path);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($path);
         self::assertSame(FlashMessage::OK, $node->_call('createDirectory')->getSeverity());
     }
 
     /**
      * @test
      */
-    public function createDirectoryReturnsErrorStatusIfDirectoryWasNotCreated()
+    public function createDirectoryReturnsErrorStatusIfDirectoryWasNotCreated(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
@@ -484,15 +472,15 @@ class DirectoryNodeTest extends FolderStructureTestCase
         chmod($path, 02550);
         $subPath = $path . '/' . $this->getUniqueId('dir_');
         $node->expects(self::once())->method('exists')->willReturn(false);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($subPath);
-        $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($subPath);
+        $node->method('getAbsolutePath')->willReturn($subPath);
+        $node->method('getRelativePathBelowSiteRoot')->willReturn($subPath);
         self::assertSame(FlashMessage::ERROR, $node->_call('createDirectory')->getSeverity());
     }
 
     /**
      * @test
      */
-    public function createChildrenThrowsExceptionIfAChildTypeIsNotSet()
+    public function createChildrenThrowsExceptionIfAChildTypeIsNotSet(): void
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionCode(1366222204);
@@ -509,7 +497,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function createChildrenThrowsExceptionIfAChildNameIsNotSet()
+    public function createChildrenThrowsExceptionIfAChildNameIsNotSet(): void
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionCode(1366222205);
@@ -526,7 +514,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function createChildrenThrowsExceptionForMultipleChildrenWithSameName()
+    public function createChildrenThrowsExceptionForMultipleChildrenWithSameName(): void
     {
         $this->expectException(InvalidArgumentException::class);
         $this->expectExceptionCode(1366222206);
@@ -548,7 +536,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function getChildrenReturnsCreatedChild()
+    public function getChildrenReturnsCreatedChild(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['dummy'], [], '', false);
@@ -575,31 +563,31 @@ class DirectoryNodeTest extends FolderStructureTestCase
     /**
      * @test
      */
-    public function isWritableReturnsFalseIfNodeDoesNotExist()
+    public function isWritableReturnsFalseIfNodeDoesNotExist(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['getAbsolutePath'], [], '', false);
         $path = $this->getVirtualTestFilePath('dir_');
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
+        $node->method('getAbsolutePath')->willReturn($path);
         self::assertFalse($node->isWritable());
     }
 
     /**
      * @test
      */
-    public function isWritableReturnsTrueIfNodeExistsAndFileCanBeCreated()
+    public function isWritableReturnsTrueIfNodeExistsAndFileCanBeCreated(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['getAbsolutePath'], [], '', false);
         $path = $this->getVirtualTestDir('root_');
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
+        $node->method('getAbsolutePath')->willReturn($path);
         self::assertTrue($node->isWritable());
     }
 
     /**
      * @test
      */
-    public function isWritableReturnsFalseIfNodeExistsButFileCanNotBeCreated()
+    public function isWritableReturnsFalseIfNodeExistsButFileCanNotBeCreated(): void
     {
         if (function_exists('posix_getegid') && posix_getegid() === 0) {
             self::markTestSkipped('Test skipped if run on linux as root');
@@ -608,19 +596,19 @@ class DirectoryNodeTest extends FolderStructureTestCase
         $node = $this->getAccessibleMock(DirectoryNode::class, ['getAbsolutePath'], [], '', false);
         $path = $this->getVirtualTestDir('root_');
         chmod($path, 02550);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
+        $node->method('getAbsolutePath')->willReturn($path);
         self::assertFalse($node->isWritable());
     }
 
     /**
      * @test
      */
-    public function isDirectoryReturnsTrueIfNameIsADirectory()
+    public function isDirectoryReturnsTrueIfNameIsADirectory(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['getAbsolutePath'], [], '', false);
         $path = $this->getVirtualTestDir('dir_');
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
+        $node->method('getAbsolutePath')->willReturn($path);
         self::assertTrue($node->_call('isDirectory'));
     }
 
@@ -628,7 +616,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
      * @test
      * @see https://github.com/mikey179/vfsStream/wiki/Known-Issues - symlink doesn't work with vfsStream
      */
-    public function isDirectoryReturnsFalseIfNameIsALinkToADirectory()
+    public function isDirectoryReturnsFalseIfNameIsALinkToADirectory(): void
     {
         /** @var $node DirectoryNode|AccessibleObjectInterface|\PHPUnit\Framework\MockObject\MockObject */
         $node = $this->getAccessibleMock(DirectoryNode::class, ['getAbsolutePath'], [], '', false);
@@ -639,7 +627,7 @@ class DirectoryNodeTest extends FolderStructureTestCase
         $dir = $this->getUniqueId('dir_');
         mkdir($path . '/' . $dir);
         symlink($path . '/' . $dir, $path . '/' . $link);
-        $node->expects(self::any())->method('getAbsolutePath')->willReturn($path . '/' . $link);
+        $node->method('getAbsolutePath')->willReturn($path . '/' . $link);
         self::assertFalse($node->_call('isDirectory'));
     }
 }
index 2a004a6..85a05cc 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper;
 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
 
 /**
@@ -32,7 +33,7 @@ class PhpErrorCodeViewHelperTest extends ViewHelperBaseTestcase
     protected function setUp(): void
     {
         parent::setUp();
-        $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper::class, ['dummy']);
+        $this->viewHelper = new PhpErrorCodeViewHelper();
         $this->injectDependenciesIntoViewHelper($this->viewHelper);
         $this->viewHelper->initializeArguments();
     }
@@ -40,7 +41,7 @@ class PhpErrorCodeViewHelperTest extends ViewHelperBaseTestcase
     /**
      * @return array
      */
-    public function errorCodesDataProvider()
+    public function errorCodesDataProvider(): array
     {
         return [
             [
@@ -68,7 +69,7 @@ class PhpErrorCodeViewHelperTest extends ViewHelperBaseTestcase
      * @test
      * @dataProvider errorCodesDataProvider
      */
-    public function renderPhpCodesCorrectly($errorCode, $expectedString)
+    public function renderPhpCodesCorrectly($errorCode, $expectedString): void
     {
         $this->viewHelper->setArguments([
             'phpErrorCode' => $errorCode
index 4653d48..539c04c 100644 (file)
@@ -26,20 +26,20 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class AddonRegistryTest extends UnitTestCase
 {
     /**
-     * @var AddonRegistry|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
+     * @var AddonRegistry
      */
     protected $subject;
 
     protected function setUp(): void
     {
-        $this->subject = $this->getAccessibleMock(AddonRegistry::class, ['dummy'], [], '', false);
+        $this->subject = new AddonRegistry();
         $this->registerAddons();
     }
 
     /**
      * Register addons for tests
      */
-    protected function registerAddons()
+    protected function registerAddons(): void
     {
         $this->subject
             ->register(GeneralUtility::makeInstance(Addon::class, 'addon/global'))
@@ -72,7 +72,7 @@ class AddonRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function globalAddonsGetReturned()
+    public function globalAddonsGetReturned(): void
     {
         $expected = [
             'addon/global',
@@ -92,7 +92,7 @@ class AddonRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function globalAndModeAddonsGetReturned()
+    public function globalAndModeAddonsGetReturned(): void
     {
         $expected = [
             'addon/global',
@@ -113,7 +113,7 @@ class AddonRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function settingsAreProperlyCompiled()
+    public function settingsAreProperlyCompiled(): void
     {
         $expected = [
             'foobar' => false,
index c0ed1dc..e7b60db 100644 (file)
@@ -26,19 +26,19 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class ModeRegistryTest extends UnitTestCase
 {
     /**
-     * @var ModeRegistry|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
+     * @var ModeRegistry
      */
     protected $subject;
 
     protected function setUp(): void
     {
-        $this->subject = $this->getAccessibleMock(ModeRegistry::class, ['dummy'], [], '', false);
+        $this->subject = new ModeRegistry();
     }
 
     /**
      * @test
      */
-    public function identifierIsReturned()
+    public function identifierIsReturned(): void
     {
         $expected = GeneralUtility::makeInstance(Mode::class, 'test/mode/default/default');
         $this->subject->register($expected);
@@ -50,7 +50,7 @@ class ModeRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function latestDefaultModeIsReturned()
+    public function latestDefaultModeIsReturned(): void
     {
         $firstDefaultMode = GeneralUtility::makeInstance(Mode::class, 'test/another/foo/bar')->setAsDefault();
         $expected = GeneralUtility::makeInstance(Mode::class, 'test/another/defaultmode/defaultmode')->setAsDefault();
@@ -63,7 +63,7 @@ class ModeRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function formatCodeReturnsCorrectMode()
+    public function formatCodeReturnsCorrectMode(): void
     {
         $expected = GeneralUtility::makeInstance(Mode::class, 'test/mode/format/code')->setFormatCode('code');
         $this->subject->register($expected);
@@ -75,7 +75,7 @@ class ModeRegistryTest extends UnitTestCase
     /**
      * @test
      */
-    public function modeIsFetchedByFileExtension()
+    public function modeIsFetchedByFileExtension(): void
     {
         $expected = GeneralUtility::makeInstance(Mode::class, 'test/mode/extension/extension')->bindToFileExtensions(['ext', 'fext']);
         $this->subject->register($expected);