From 0e5d0d7cacdac2abc04bc4d05ccdf489b9174202 Mon Sep 17 00:00:00 2001 From: Georg Ringer Date: Tue, 4 Jul 2023 08:42:09 +0200 Subject: [PATCH] [TASK] Automated cleanup via rector --- Build/Test/IntegrationTestsBootstrap.php | 4 +- Build/Test/UnitTestsBootstrap.php | 53 ++++++++++++------- .../TikaControlPanelModuleController.php | 10 ++-- .../Tika/ServiceIntegrationTestCase.php | 4 +- 4 files changed, 43 insertions(+), 28 deletions(-) diff --git a/Build/Test/IntegrationTestsBootstrap.php b/Build/Test/IntegrationTestsBootstrap.php index ec3208b8..8e08ef52 100644 --- a/Build/Test/IntegrationTestsBootstrap.php +++ b/Build/Test/IntegrationTestsBootstrap.php @@ -2,6 +2,8 @@ declare(strict_types=1); +use TYPO3\TestingFramework\Core\Testbase; + /* * This file is part of the TYPO3 CMS project. * @@ -16,7 +18,7 @@ */ call_user_func(function () { - $testbase = new \TYPO3\TestingFramework\Core\Testbase(); + $testbase = new Testbase(); $testbase->defineOriginalRootPath(); $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/tests'); $testbase->createDirectory(ORIGINAL_ROOT . 'typo3temp/var/transient'); diff --git a/Build/Test/UnitTestsBootstrap.php b/Build/Test/UnitTestsBootstrap.php index 533287ac..f31a4c7c 100644 --- a/Build/Test/UnitTestsBootstrap.php +++ b/Build/Test/UnitTestsBootstrap.php @@ -2,6 +2,19 @@ declare(strict_types=1); +use TYPO3\TestingFramework\Core\Testbase; +use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; +use TYPO3\CMS\Core\Core\Environment; +use TYPO3\CMS\Core\Core\Bootstrap; +use TYPO3\CMS\Core\Configuration\ConfigurationManager; +use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend; +use TYPO3\CMS\Core\Cache\Backend\NullBackend; +use TYPO3\CMS\Core\Package\Cache\PackageCacheInterface; +use TYPO3\CMS\Core\Package\UnitTestPackageManager; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Package\PackageManager; +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; + /* * This file is part of the TYPO3 CMS project. * @@ -16,7 +29,7 @@ */ call_user_func(function () { - $testbase = new \TYPO3\TestingFramework\Core\Testbase(); + $testbase = new Testbase(); // These if's are for core testing (package typo3/cms) only. cms-composer-installer does // not create the autoload-include.php file that sets these env vars and sets composer @@ -34,45 +47,45 @@ $testbase->defineSitePath(); - $requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI; - \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::run(0, $requestType); + $requestType = SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI; + SystemEnvironmentBuilder::run(0, $requestType); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3conf/ext'); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/assets'); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/tests'); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/transient'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3conf/ext'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/assets'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/tests'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/transient'); // Retrieve an instance of class loader and inject to core bootstrap $classLoader = require $testbase->getPackagesPath() . '/autoload.php'; - \TYPO3\CMS\Core\Core\Bootstrap::initializeClassLoader($classLoader); + Bootstrap::initializeClassLoader($classLoader); // Initialize default TYPO3_CONF_VARS - $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager(); + $configurationManager = new ConfigurationManager(); $GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration(); - $cache = new \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend( + $cache = new PhpFrontend( 'core', - new \TYPO3\CMS\Core\Cache\Backend\NullBackend('production', []) + new NullBackend('production', []) ); // Set all packages to active - if (interface_exists(\TYPO3\CMS\Core\Package\Cache\PackageCacheInterface::class)) { - $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager( - \TYPO3\CMS\Core\Package\UnitTestPackageManager::class, - \TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache) + if (interface_exists(PackageCacheInterface::class)) { + $packageManager = Bootstrap::createPackageManager( + UnitTestPackageManager::class, + Bootstrap::createPackageCache($cache) ); } else { // v10 compatibility layer - $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager( - \TYPO3\CMS\Core\Package\UnitTestPackageManager::class, + $packageManager = Bootstrap::createPackageManager( + UnitTestPackageManager::class, $cache ); } - \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager); + GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager); + ExtensionManagementUtility::setPackageManager($packageManager); $testbase->dumpClassLoadingInformation(); - \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances(); + GeneralUtility::purgeInstances(); }); diff --git a/Classes/Controller/Backend/SolrModule/TikaControlPanelModuleController.php b/Classes/Controller/Backend/SolrModule/TikaControlPanelModuleController.php index 87acf9a8..99431dd8 100644 --- a/Classes/Controller/Backend/SolrModule/TikaControlPanelModuleController.php +++ b/Classes/Controller/Backend/SolrModule/TikaControlPanelModuleController.php @@ -16,7 +16,7 @@ * * The TYPO3 project - inspiring people to share! */ - +use TYPO3\CMS\Core\Messaging\AbstractMessage; use ApacheSolrForTypo3\Solr\Controller\Backend\Search\AbstractModuleController; use ApacheSolrForTypo3\Tika\Service\Tika\AbstractService; use ApacheSolrForTypo3\Tika\Service\Tika\AppService; @@ -149,7 +149,7 @@ public function startServerAction(): ResponseInterface if ($this->tikaService->/** @scrutinizer ignore-call */isServerRunning()) { $this->addFlashMessage( 'Tika server started.', - FlashMessage::OK + AbstractMessage::OK ); } @@ -170,7 +170,7 @@ public function stopServerAction(): ResponseInterface if (!$this->tikaService->/** @scrutinizer ignore-call */ isServerRunning()) { $this->addFlashMessage( 'Tika server stopped.', - FlashMessage::OK + AbstractMessage::OK ); } @@ -270,13 +270,13 @@ protected function checkTikaServerConnection(): void $this->addFlashMessage( 'Tika host contacted at: ' . $this->tikaService->/** @scrutinizer ignore-call */getTikaServerUrl(), 'Your Apache Tika server has been contacted.', - FlashMessage::OK + AbstractMessage::OK ); } else { $this->addFlashMessage( 'Could not connect to Tika at: ' . $this->tikaService->/** @scrutinizer ignore-call */getTikaServerUrl(), 'Unable to contact Apache Tika server.', - FlashMessage::ERROR + AbstractMessage::ERROR ); } } diff --git a/Tests/Integration/Service/Tika/ServiceIntegrationTestCase.php b/Tests/Integration/Service/Tika/ServiceIntegrationTestCase.php index 00aa5833..43a7c8cc 100644 --- a/Tests/Integration/Service/Tika/ServiceIntegrationTestCase.php +++ b/Tests/Integration/Service/Tika/ServiceIntegrationTestCase.php @@ -16,7 +16,7 @@ * * The TYPO3 project - inspiring people to share! */ - +use TYPO3\CMS\Core\EventDispatcher\EventDispatcher; use InvalidArgumentException; use PHPUnit\Framework\MockObject\MockObject; use Prophecy\PhpUnit\ProphecyTrait; @@ -135,7 +135,7 @@ protected function setUp(): void /** @noinspection PhpFullyQualifiedNameUsageInspection */ $metaDataRepositoryConstructorArgs = [ - GeneralUtility::makeInstance(\TYPO3\CMS\Core\EventDispatcher\EventDispatcher::class), + GeneralUtility::makeInstance(EventDispatcher::class), ]; /* @var MetaDataRepository|MockObject $mockedMetaDataRepository */