[TASK] Avoid mocking methods that don't exist
phpunit 10 removed ->setMethods() on mocks. This is especially problematic with typo3/testing-framework, which provides ->getAccessibleMock(). The scope of this API is to "open up" sub methods of a class, to check if they are called with this-or-that argument, and to return some value as mock, while keeping other parts of the mocked class as-is. TF ->getAccessibleMock() will have to change from using ->setMethods() for phpunit 10 support. It will switch to ->onlyMethods() instead. The difference between setMethods() and onlyMethods() is, that onlyMethods() throws an exception if a method to-be-mocked method does not exist, while setMethods() did not do that. We do *not* want to implement some API within TF ->getAccessibleMock() (and friends) to check if some method actually exists in a to-mock class, we'll switch to onlyMethods() and will avoid additional magic that would be potentially available using ->addMethods(). As such, we need to get rid of all calls within the TYPO3 core that try to create mocks of methods that don't exist. There are a couple of hard nuts. This patch solves the easy cases, more complicated use cases will be sorted out with dedicated patches. Strategy with this patch: * Use 'null' instead of ['dummy'] to mock no method and only have an accessible proxy. 'dummy' has been used a lot in the past, has been removed a lot already, but left overs need to be removed now. * Avoid mocking methods in tests that have been removed meanwhile. That part is the good thing of phpunit 10: It forces tests to keep up with the system under test in case it removed methods, so we don't end up with dead method mocks. Resolves: #100273 Related: #100249 Change-Id: If93ec4b87fdad15954ba0c17d868cd8f1165d372 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78223 Tested-by:Nikita Hovratov <nikita.h@live.de> Tested-by:
Markus Klein <markus.klein@typo3.org> Reviewed-by:
Markus Klein <markus.klein@typo3.org> Reviewed-by:
Nikita Hovratov <nikita.h@live.de> Reviewed-by:
Christian Kuhn <lolli@schwarzbu.ch> Tested-by:
core-ci <typo3@b13.com> Tested-by:
Christian Kuhn <lolli@schwarzbu.ch>
Showing
- typo3/sysext/core/Tests/Unit/FormProtection/InstallToolFormProtectionTest.php 6 additions, 33 deletions...sts/Unit/FormProtection/InstallToolFormProtectionTest.php
- typo3/sysext/core/Tests/Unit/Log/Processor/IntrospectionProcessorTest.php 1 addition, 4 deletions...e/Tests/Unit/Log/Processor/IntrospectionProcessorTest.php
- typo3/sysext/core/Tests/Unit/Resource/FileReferenceTest.php 2 additions, 3 deletionstypo3/sysext/core/Tests/Unit/Resource/FileReferenceTest.php
- typo3/sysext/core/Tests/Unit/Resource/StorageRepositoryTest.php 1 addition, 1 deletion...sysext/core/Tests/Unit/Resource/StorageRepositoryTest.php
- typo3/sysext/extbase/Tests/Unit/Configuration/FrontendConfigurationManagerTest.php 1 addition, 1 deletion...s/Unit/Configuration/FrontendConfigurationManagerTest.php
- typo3/sysext/extensionmanager/Tests/Unit/Controller/ActionControllerTest.php 1 addition, 6 deletions...ionmanager/Tests/Unit/Controller/ActionControllerTest.php
- typo3/sysext/extensionmanager/Tests/Unit/Utility/InstallUtilityTest.php 0 additions, 2 deletions...xtensionmanager/Tests/Unit/Utility/InstallUtilityTest.php
- typo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php 3 additions, 3 deletionstypo3/sysext/fluid/Tests/Unit/View/TemplatePathsTest.php
- typo3/sysext/form/Tests/Unit/Controller/FormEditorControllerTest.php 7 additions, 21 deletions...t/form/Tests/Unit/Controller/FormEditorControllerTest.php
- typo3/sysext/form/Tests/Unit/Controller/FormFrontendControllerTest.php 3 additions, 9 deletions...form/Tests/Unit/Controller/FormFrontendControllerTest.php
- typo3/sysext/form/Tests/Unit/Controller/FormManagerControllerTest.php 10 additions, 30 deletions.../form/Tests/Unit/Controller/FormManagerControllerTest.php
- typo3/sysext/form/Tests/Unit/Domain/Finishers/SaveToDatabaseFinisherTest.php 1 addition, 6 deletions...ests/Unit/Domain/Finishers/SaveToDatabaseFinisherTest.php
- typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractFormElementTest.php 4 additions, 20 deletions...ests/Unit/Domain/FormElements/AbstractFormElementTest.php
- typo3/sysext/form/Tests/Unit/Mvc/Configuration/YamlSourceTest.php 3 additions, 9 deletions...sext/form/Tests/Unit/Mvc/Configuration/YamlSourceTest.php
- typo3/sysext/form/Tests/Unit/Mvc/Persistence/FormPersistenceManagerTest.php 5 additions, 33 deletions...Tests/Unit/Mvc/Persistence/FormPersistenceManagerTest.php
- typo3/sysext/impexp/Tests/Unit/ExportTest.php 1 addition, 1 deletiontypo3/sysext/impexp/Tests/Unit/ExportTest.php
- typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php 19 additions, 19 deletions...ts/Unit/Service/SilentConfigurationUpgradeServiceTest.php
- typo3/sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php 1 addition, 1 deletion.../sysext/seo/Tests/Unit/HrefLang/HrefLangGeneratorTest.php
- typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php 1 addition, 1 deletion...kspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php
Please register or sign in to comment