From 7e9417907c51326a57cab8b6ef187a82476d133e Mon Sep 17 00:00:00 2001
From: Nikita Hovratov <nikita.h@live.de>
Date: Sat, 12 Nov 2022 17:37:19 +0100
Subject: [PATCH] [TASK] Replace prophecy in EXT:core PageTsConfigLoaderTest
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Resolves: #98752
Releases: main
Change-Id: I8b5229ca9d2eb86072ae21a775d9368133cbba54
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76573
Tested-by: core-ci <typo3@b13.com>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
---
 .../Loader/PageTsConfigLoaderTest.php         | 28 ++++++++-----------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/typo3/sysext/core/Tests/Unit/Configuration/Loader/PageTsConfigLoaderTest.php b/typo3/sysext/core/Tests/Unit/Configuration/Loader/PageTsConfigLoaderTest.php
index dbf6e4f7c0a1..8dce931a326e 100644
--- a/typo3/sysext/core/Tests/Unit/Configuration/Loader/PageTsConfigLoaderTest.php
+++ b/typo3/sysext/core/Tests/Unit/Configuration/Loader/PageTsConfigLoaderTest.php
@@ -17,8 +17,6 @@ declare(strict_types=1);
 
 namespace TYPO3\CMS\Core\Tests\Unit\Configuration\Loader;
 
-use Prophecy\Argument;
-use Prophecy\PhpUnit\ProphecyTrait;
 use Psr\EventDispatcher\EventDispatcherInterface;
 use TYPO3\CMS\Core\Configuration\Event\ModifyLoadedPageTsConfigEvent;
 use TYPO3\CMS\Core\Configuration\Loader\PageTsConfigLoader;
@@ -26,8 +24,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class PageTsConfigLoaderTest extends UnitTestCase
 {
-    use ProphecyTrait;
-
     /**
      * @test
      */
@@ -37,10 +33,10 @@ class PageTsConfigLoaderTest extends UnitTestCase
             'default' => $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'],
         ];
         $expectedString = implode('"\n[GLOBAL]\n"', $expected);
-        $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
-        $subject = new PageTsConfigLoader($eventDispatcher->reveal());
+        $eventDispatcherMock = $this->createMock(EventDispatcherInterface::class);
+        $subject = new PageTsConfigLoader($eventDispatcherMock);
         $event = new ModifyLoadedPageTsConfigEvent($expected, []);
-        $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
+        $eventDispatcherMock->method('dispatch')->with(self::isInstanceOf(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
         $result = $subject->collect([]);
         self::assertSame($expected, $result);
 
@@ -59,10 +55,10 @@ class PageTsConfigLoaderTest extends UnitTestCase
             'page_27' => '',
         ];
         $rootLine = [['uid' => 0, 'pid' => 0], ['uid' => 13, 'TSconfig' => 'waiting for = love'], ['uid' => 27, 'TSconfig' => '']];
-        $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
+        $eventDispatcherMock = $this->createMock(EventDispatcherInterface::class);
         $event = new ModifyLoadedPageTsConfigEvent($expected, $rootLine);
-        $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
-        $subject = new PageTsConfigLoader($eventDispatcher->reveal());
+        $eventDispatcherMock->method('dispatch')->with(self::isInstanceOf(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
+        $subject = new PageTsConfigLoader($eventDispatcherMock);
         $result = $subject->collect($rootLine);
         self::assertSame($expected, $result);
     }
@@ -80,10 +76,10 @@ class PageTsConfigLoaderTest extends UnitTestCase
             'page_27' => '',
         ];
         $rootLine = [['uid' => 13, 'TSconfig' => 'waiting for = love', 'tsconfig_includes' => 'EXT:core/Tests/Unit/Configuration/Loader/Fixtures/included.typoscript'], ['uid' => 27, 'TSconfig' => '']];
-        $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
+        $eventDispatcherMock = $this->createMock(EventDispatcherInterface::class);
         $event = new ModifyLoadedPageTsConfigEvent($expected, $rootLine);
-        $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
-        $subject = new PageTsConfigLoader($eventDispatcher->reveal());
+        $eventDispatcherMock->method('dispatch')->with(self::isInstanceOf(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
+        $subject = new PageTsConfigLoader($eventDispatcherMock);
         $result = $subject->collect($rootLine);
         self::assertSame($expected, $result);
     }
@@ -100,10 +96,10 @@ class PageTsConfigLoaderTest extends UnitTestCase
         ];
         $expectedString = implode("\n[GLOBAL]\n", $expected);
         $rootLine = [['uid' => 13, 'TSconfig' => 'waiting for = love', 'tsconfig_includes' => 'EXT:core/Tests/Unit/Configuration/Loader/Fixtures/me_does_not_exist.typoscript'], ['uid' => 27, 'TSconfig' => '']];
-        $eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
+        $eventDispatcherMock = $this->createMock(EventDispatcherInterface::class);
         $event = new ModifyLoadedPageTsConfigEvent($expected, $rootLine);
-        $eventDispatcher->dispatch(Argument::type(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
-        $subject = new PageTsConfigLoader($eventDispatcher->reveal());
+        $eventDispatcherMock->method('dispatch')->with(self::isInstanceOf(ModifyLoadedPageTsConfigEvent::class))->willReturn($event);
+        $subject = new PageTsConfigLoader($eventDispatcherMock);
         $result = $subject->collect($rootLine);
         self::assertSame($expected, $result);
 
-- 
GitLab