From 248832dd917c697c15fb2d186f6218030faf5d3c Mon Sep 17 00:00:00 2001 From: Nikita Hovratov <nikita.h@live.de> Date: Sat, 12 Nov 2022 17:12:55 +0100 Subject: [PATCH] [TASK] Replace prophecy in EXT:core ExtensionConfigurationTest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: #98751 Releases: main Change-Id: I5e127bebb5fdab914c535c7f16f1ff85ce1d9778 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76572 Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: core-ci <typo3@b13.com> Tested-by: Oliver Klee <typo3-coding@oliverklee.de> Tested-by: Stefan Bürk <stefan@buerk.tech> --- .../ExtensionConfigurationTest.php | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php b/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php index fede7c5026e3..3c8018d6fe3c 100644 --- a/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php +++ b/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php @@ -17,8 +17,6 @@ declare(strict_types=1); namespace TYPO3\CMS\Core\Tests\Unit\Configuration; -use Prophecy\Argument; -use Prophecy\PhpUnit\ProphecyTrait; use TYPO3\CMS\Core\Configuration\ConfigurationManager; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -26,8 +24,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; class ExtensionConfigurationTest extends UnitTestCase { - use ProphecyTrait; - /** * @test */ @@ -86,10 +82,14 @@ class ExtensionConfigurationTest extends UnitTestCase */ public function setRemovesFullExtensionConfiguration(): void { - $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class); - GeneralUtility::addInstance(ConfigurationManager::class, $configurationManagerProphecy->reveal()); - $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/foo'])->shouldBeCalled(); + $configurationManagerMock = $this->createMock(ConfigurationManager::class); + GeneralUtility::addInstance(ConfigurationManager::class, $configurationManagerMock); + $configurationManagerMock->expects(self::once())->method('removeLocalConfigurationKeysByPath')->with(['EXTENSIONS/foo']); + $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['foo'] = [ + 'bar' => 'baz', + ]; (new ExtensionConfiguration())->set('foo'); + self::assertFalse(isset($GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['foo'])); } /** @@ -97,10 +97,15 @@ class ExtensionConfigurationTest extends UnitTestCase */ public function setWritesFullExtensionConfig(): void { - $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class); - GeneralUtility::addInstance(ConfigurationManager::class, $configurationManagerProphecy->reveal()); - $configurationManagerProphecy->setLocalConfigurationValueByPath(Argument::cetera())->shouldBeCalled(); - $configurationManagerProphecy->setLocalConfigurationValueByPath('EXTENSIONS/foo', ['bar' => 'baz'])->shouldBeCalled(); - (new ExtensionConfiguration())->set('foo', ['bar' => 'baz']); + $value = ['bar' => 'baz']; + $configurationManagerMock = $this->createMock(ConfigurationManager::class); + GeneralUtility::addInstance(ConfigurationManager::class, $configurationManagerMock); + $configurationManagerMock->expects(self::once())->method('setLocalConfigurationValueByPath')->with('EXTENSIONS/foo', $value); + $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['foo'] = [ + 'bar' => 'fizz', + 'bee' => 'boo', + ]; + (new ExtensionConfiguration())->set('foo', $value); + self::assertSame($value, $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['foo']); } } -- GitLab