Skip to content

Commit

Permalink
[BUGFIX] Avoid incomplete setup in ExtensionStatusTest
Browse files Browse the repository at this point in the history
Since PHP 8.1 passing null as first argument
($format) has been deprecated. LanguageService
uses 'sprintf()' for  formatting messages.

In normal instances LanguageService would
return translated keys, or at least an empty
string.

Tests in ExtensionStatusTest has been mocking
the LanguageService, without correctly mocking
some methods, thus return null on translation.
This leads to 'sprintf()' calls with null
instead of empty strings, thus spawning these
depcrecation messages.

This patch add mocks for some methods of the
LanguageService mock to avoid these messages.

Resolves: #95739
Releases: master
Change-Id: Ie922dc1b30b05ff482d117c1219a372b3da0e997
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71942
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
sbuerk authored and lolli42 committed Oct 23, 2021
1 parent 19488f7 commit 057d9f8
Showing 1 changed file with 25 additions and 5 deletions.
Expand Up @@ -191,8 +191,12 @@ public function getStatusReturnsOkForLoadedExtensionIfNoInsecureExtensionIsLoade
*/
public function getStatusReturnsErrorForLoadedExtensionIfInsecureExtensionIsLoaded(): void
{
$languageServiceProphecy = $this->prophesize(LanguageService::class);
$languageServiceProphecy->includeLLFile(Argument::any())->willReturn('');
$languageServiceProphecy->getLL(Argument::any())->willReturn('');
$languageServiceProphecy->getLLL(Argument::any())->willReturn('');
$languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class);
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($this->prophesize(LanguageService::class)->reveal());
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($languageServiceProphecy->reveal());
GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal());

$remoteRegistryProphecy = $this->setUpRegistryStatusTests(-1);
Expand All @@ -208,8 +212,12 @@ public function getStatusReturnsErrorForLoadedExtensionIfInsecureExtensionIsLoad
*/
public function getStatusReturnsOkForExistingExtensionIfNoInsecureExtensionExists(): void
{
$languageServiceProphecy = $this->prophesize(LanguageService::class);
$languageServiceProphecy->includeLLFile(Argument::any())->willReturn('');
$languageServiceProphecy->getLL(Argument::any())->willReturn('');
$languageServiceProphecy->getLLL(Argument::any())->willReturn('');
$languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class);
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($this->prophesize(LanguageService::class)->reveal());
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($languageServiceProphecy->reveal());
GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal());

$remoteRegistryProphecy = $this->setUpRegistryStatusTests(0, false);
Expand All @@ -226,8 +234,12 @@ public function getStatusReturnsOkForExistingExtensionIfNoInsecureExtensionExist
*/
public function getStatusReturnsWarningForExistingExtensionIfInsecureExtensionExistsButIsNotLoaded(): void
{
$languageServiceProphecy = $this->prophesize(LanguageService::class);
$languageServiceProphecy->includeLLFile(Argument::any())->willReturn('');
$languageServiceProphecy->getLL(Argument::any())->willReturn('');
$languageServiceProphecy->getLLL(Argument::any())->willReturn('');
$languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class);
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($this->prophesize(LanguageService::class)->reveal());
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($languageServiceProphecy->reveal());
GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal());

$remoteRegistryProphecy = $this->setUpRegistryStatusTests(-1, false);
Expand All @@ -243,8 +255,12 @@ public function getStatusReturnsWarningForExistingExtensionIfInsecureExtensionEx
*/
public function getStatusReturnsWarningForLoadedExtensionIfOutdatedExtensionIsLoaded(): void
{
$languageServiceProphecy = $this->prophesize(LanguageService::class);
$languageServiceProphecy->includeLLFile(Argument::any())->willReturn('');
$languageServiceProphecy->getLL(Argument::any())->willReturn('');
$languageServiceProphecy->getLLL(Argument::any())->willReturn('');
$languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class);
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($this->prophesize(LanguageService::class)->reveal());
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($languageServiceProphecy->reveal());
GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal());

$remoteRegistryProphecy = $this->setUpRegistryStatusTests(-2, true);
Expand All @@ -260,8 +276,12 @@ public function getStatusReturnsWarningForLoadedExtensionIfOutdatedExtensionIsLo
*/
public function getStatusReturnsErrorForExistingExtensionIfOutdatedExtensionExists(): void
{
$languageServiceProphecy = $this->prophesize(LanguageService::class);
$languageServiceProphecy->includeLLFile(Argument::any())->willReturn('');
$languageServiceProphecy->getLL(Argument::any())->willReturn('');
$languageServiceProphecy->getLLL(Argument::any())->willReturn('');
$languageServiceFactoryProphecy = $this->prophesize(LanguageServiceFactory::class);
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($this->prophesize(LanguageService::class)->reveal());
$languageServiceFactoryProphecy->createFromUserPreferences(Argument::cetera())->willReturn($languageServiceProphecy->reveal());
GeneralUtility::addInstance(LanguageServiceFactory::class, $languageServiceFactoryProphecy->reveal());

$remoteRegistryProphecy = $this->setUpRegistryStatusTests(-2, false);
Expand Down

0 comments on commit 057d9f8

Please sign in to comment.