Skip to content

Commit 91afc03

Browse files
authored
[TASK] Remove unused TYPO3 Core context initialization in integration tests (#4568)
* Delete unused `initializeTypo3CoreContextForApplication()` method * Remove redundant properties and cleanup `setUp()` and `tearDown()` methods * Clean up unused import statements in `IntegrationTestBase.php` * Improve readability and maintainability of the code
1 parent 62453ef commit 91afc03

1 file changed

Lines changed: 2 additions & 58 deletions

File tree

Tests/Integration/IntegrationTestBase.php

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,17 @@
2727
use ReflectionException;
2828
use ReflectionObject;
2929
use Throwable;
30-
use TYPO3\CMS\Backend\Http\Application as BackendApplication;
3130
use TYPO3\CMS\Core\Cache\CacheManager;
3231
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
3332
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
34-
use TYPO3\CMS\Core\Console\CommandApplication;
35-
use TYPO3\CMS\Core\Context\Context;
36-
use TYPO3\CMS\Core\Context\DateTimeAspect;
37-
use TYPO3\CMS\Core\Context\UserAspect;
38-
use TYPO3\CMS\Core\Context\VisibilityAspect;
39-
use TYPO3\CMS\Core\Context\WorkspaceAspect;
4033
use TYPO3\CMS\Core\Core\Environment;
4134
use TYPO3\CMS\Core\Database\ConnectionPool;
42-
use TYPO3\CMS\Core\Domain\DateTimeFactory;
4335
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
4436
use TYPO3\CMS\Core\Http\RequestFactory;
4537
use TYPO3\CMS\Core\Site\Entity\Site;
4638
use TYPO3\CMS\Core\Site\SiteFinder;
4739
use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait;
4840
use TYPO3\CMS\Core\Utility\GeneralUtility;
49-
use TYPO3\CMS\Frontend\Http\Application as FrontendApplication;
5041
use TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository;
5142
use TYPO3\CMS\Scheduler\Scheduler;
5243
use TYPO3\CMS\Scheduler\Task\TaskSerializer;
@@ -100,14 +91,10 @@ abstract class IntegrationTestBase extends FunctionalTestCase
10091
*/
10192
protected bool $skipImportRootPagesAndTemplatesForConfiguredSites = false;
10293

103-
protected ?string $typo3CoreContextApplicationType = CommandApplication::class;
104-
105-
protected ?Context $typo3CoreContext = null;
106-
10794
protected function setUp(): void
10895
{
10996
parent::setUp();
110-
$this->initializeTypo3CoreContextForApplication();
97+
11198
//this is needed by the TYPO3 core.
11299
chdir(Environment::getPublicPath() . '/');
113100
$this->instancePath = $this->getInstancePath();
@@ -117,7 +104,7 @@ protected function setUp(): void
117104
protected function tearDown(): void
118105
{
119106
set_error_handler($this->previousErrorHandler);
120-
unset($this->typo3CoreContext);
107+
121108
parent::tearDown();
122109
}
123110

@@ -612,47 +599,4 @@ protected function addSimpleFrontendRenderingToTypoScriptRendering(int $template
612599
}
613600
' . $additionalContent);
614601
}
615-
616-
/**
617-
* EXT:solr runs in multiple TYPO3 application types:
618-
* * Frontend for search only
619-
* * Backend for indexing
620-
* * Command for indexing and/or EXT:solrconsole
621-
*
622-
* The EXT:solr stack for integration-tests has multiple issues, due to shortage booting real TYPO3 environment.
623-
* The tests do not fail on integration-tests or behave different as on real TYPO3 system.
624-
*
625-
* If you want own TYPO3 core context state: unset {@link self::$typo3CoreContextApplicationType} on test class property
626-
* and figure it in `setUp()` method as you want.
627-
*/
628-
protected function initializeTypo3CoreContextForApplication(): void
629-
{
630-
if (empty($this->typo3CoreContextApplicationType)) {
631-
return;
632-
}
633-
634-
if ($this->typo3CoreContext === null) {
635-
$this->typo3CoreContext = GeneralUtility::makeInstance(Context::class);
636-
}
637-
638-
$this->typo3CoreContext->setAspect('date', new DateTimeAspect(DateTimeFactory::createFromTimestamp(time())));
639-
switch ($this->typo3CoreContextApplicationType) {
640-
case CommandApplication::class:
641-
$this->typo3CoreContext->setAspect('visibility', new VisibilityAspect(true, true, false, true));
642-
$this->typo3CoreContext->setAspect('workspace', new WorkspaceAspect(0));
643-
$this->typo3CoreContext->setAspect('backend.user', new UserAspect(null));
644-
break;
645-
case BackendApplication::class:
646-
$this->typo3CoreContext->setAspect('visibility', new VisibilityAspect(true, true, false, true));
647-
break;
648-
case FrontendApplication::class:
649-
$this->typo3CoreContext->setAspect('visibility', new VisibilityAspect());
650-
$this->typo3CoreContext->setAspect('workspace', new WorkspaceAspect(0));
651-
$this->typo3CoreContext->setAspect('backend.user', new UserAspect(null));
652-
$this->typo3CoreContext->setAspect('frontend.user', new UserAspect(null, [0, -1]));
653-
break;
654-
default:
655-
break;
656-
}
657-
}
658602
}

0 commit comments

Comments
 (0)