Skip to content

Commit

Permalink
[TASK] Automated cleanup via rector
Browse files Browse the repository at this point in the history
  • Loading branch information
georgringer authored and dkd-kaehm committed Aug 15, 2023
1 parent 3e5c6c2 commit 0e5d0d7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
4 changes: 3 additions & 1 deletion Build/Test/IntegrationTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

use TYPO3\TestingFramework\Core\Testbase;

/*
* This file is part of the TYPO3 CMS project.
*
Expand All @@ -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');
Expand Down
53 changes: 33 additions & 20 deletions Build/Test/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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
Expand All @@ -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();
});
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,7 +149,7 @@ public function startServerAction(): ResponseInterface
if ($this->tikaService->/** @scrutinizer ignore-call */isServerRunning()) {
$this->addFlashMessage(
'Tika server started.',
FlashMessage::OK
AbstractMessage::OK
);
}

Expand All @@ -170,7 +170,7 @@ public function stopServerAction(): ResponseInterface
if (!$this->tikaService->/** @scrutinizer ignore-call */ isServerRunning()) {
$this->addFlashMessage(
'Tika server stopped.',
FlashMessage::OK
AbstractMessage::OK
);
}

Expand Down Expand Up @@ -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
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Integration/Service/Tika/ServiceIntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit 0e5d0d7

Please sign in to comment.