diff --git a/Classes/IndexQueue/FrontendHelper/PageIndexer.php b/Classes/IndexQueue/FrontendHelper/PageIndexer.php index 73cc0a6371..9353f64f6e 100644 --- a/Classes/IndexQueue/FrontendHelper/PageIndexer.php +++ b/Classes/IndexQueue/FrontendHelper/PageIndexer.php @@ -28,7 +28,6 @@ use Doctrine\DBAL\Exception as DBALException; use Throwable; use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException; -use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; diff --git a/Classes/System/Language/FrontendOverlayService.php b/Classes/System/Language/FrontendOverlayService.php index 3dee0bdb7d..f5b0865f12 100644 --- a/Classes/System/Language/FrontendOverlayService.php +++ b/Classes/System/Language/FrontendOverlayService.php @@ -21,6 +21,7 @@ use Doctrine\DBAL\Driver\Exception as DBALDriverException; use Doctrine\DBAL\Exception as DBALException; use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException; +use TYPO3\CMS\Core\Context\LanguageAspect; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -32,24 +33,12 @@ class FrontendOverlayService { /** - * @var TCAService + * FrontendOverlayService constructor */ - protected $tcaService; - - /** - * @var TypoScriptFrontendController|null - */ - protected ?TypoScriptFrontendController $tsfe = null; - - /** - * Relation constructor. - * @param TCAService|null $tcaService - * @param TypoScriptFrontendController|null $tsfe - */ - public function __construct(TCAService $tcaService = null, TypoScriptFrontendController $tsfe = null) - { - $this->tcaService = $tcaService ?? GeneralUtility::makeInstance(TCAService::class); - $this->tsfe = $tsfe; + public function __construct( + protected readonly TCAService $tcaService, + protected readonly TypoScriptFrontendController $tsfe + ) { } /** @@ -57,19 +46,20 @@ public function __construct(TCAService $tcaService = null, TypoScriptFrontendCon * * @param string $tableName * @param array $record - * @return array + * + * @return array|null + * * @throws AspectNotFoundException */ public function getOverlay(string $tableName, array $record): ?array { - $currentLanguageUid = $this->tsfe->getContext()->getPropertyFromAspect('language', 'id'); - if ($tableName === 'pages') { - // @extensionScannerIgnoreLine - return $this->tsfe->sys_page->getPageOverlay($record, $currentLanguageUid); - } + /* @var LanguageAspect $currentLanguageAspect */ + $currentLanguageAspect = $this->tsfe->getContext()->getAspect('language'); +// if ($tableName === 'pages') { +// return $this->tsfe->sys_page->getPageOverlay($record, $currentLanguageAspect); +// } - // @extensionScannerIgnoreLine - return $this->tsfe->sys_page->getRecordOverlay($tableName, $record, $currentLanguageUid); + return $this->tsfe->sys_page->getLanguageOverlay($tableName, $record, $currentLanguageAspect); } /** @@ -136,11 +126,12 @@ protected function getLocalRecordUidFromOverlay(string $localTableName, array $o /** * @param string $localTableName * @param int $localRecordUid - * @return mixed - * @throws DBALDriverException - * @throws DBALException|\Doctrine\DBAL\DBALException + * + * @return array|false + * + * @throws DBALException */ - protected function getRecord(string $localTableName, int $localRecordUid) + protected function getRecord(string $localTableName, int $localRecordUid): array|false { /* @var QueryBuilder $queryBuilder */ $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($localTableName); diff --git a/Tests/Integration/Backend/SettingsPreviewOnPluginsTest.php b/Tests/Integration/Backend/SettingsPreviewOnPluginsTest.php index e113d0c7f0..98923bffd0 100644 --- a/Tests/Integration/Backend/SettingsPreviewOnPluginsTest.php +++ b/Tests/Integration/Backend/SettingsPreviewOnPluginsTest.php @@ -7,8 +7,9 @@ use PHPUnit\Framework\MockObject\MockObject; use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent; use TYPO3\CMS\Backend\View\PageLayoutContext; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Service\FlexFormService; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** * EXT:solr offers a summary in the BE on search plugins, that summarizes the extension @@ -57,8 +58,8 @@ class SettingsPreviewOnPluginsTest extends IntegrationTest protected function setUp(): void { - $GLOBALS['LANG'] = $this->createMock(LanguageService::class); parent::setUp(); + $GLOBALS['LANG'] = $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } /** diff --git a/Tests/Integration/Controller/Backend/Search/IndexAdministrationModuleControllerTest.php b/Tests/Integration/Controller/Backend/Search/IndexAdministrationModuleControllerTest.php index 7f350e89e5..2689e1c923 100644 --- a/Tests/Integration/Controller/Backend/Search/IndexAdministrationModuleControllerTest.php +++ b/Tests/Integration/Controller/Backend/Search/IndexAdministrationModuleControllerTest.php @@ -23,7 +23,7 @@ use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest; use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; use TYPO3\CMS\Core\Imaging\IconFactory; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -42,7 +42,7 @@ class IndexAdministrationModuleControllerTest extends IntegrationTest protected function setUp(): void { parent::setUp(); - $GLOBALS['LANG'] = $this->createMock(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $this->writeDefaultSolrTestSiteConfiguration(); diff --git a/Tests/Integration/GarbageCollectorTest.php b/Tests/Integration/GarbageCollectorTest.php index 942742274a..b2f64861f0 100644 --- a/Tests/Integration/GarbageCollectorTest.php +++ b/Tests/Integration/GarbageCollectorTest.php @@ -26,7 +26,7 @@ use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\DataHandling\DataHandler; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Scheduler\Scheduler; @@ -93,6 +93,8 @@ protected function setUp(): void $this->extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); $this->eventQueue = GeneralUtility::makeInstance(EventQueueItemRepository::class); $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['solr'] = []; + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class) + ->create('default'); } protected function tearDown(): void @@ -872,7 +874,6 @@ protected function prepareCanTriggerHookAfterRecordDeletion(): void ); $this->cleanUpSolrServerAndAssertEmpty(); - $this->fakeLanguageService(); // we hide the seconde page $beUser = $this->fakeBEUser(1, 0); @@ -913,16 +914,6 @@ protected function addToQueueAndIndexRecord($table, $uid): bool return $result; } - /** - * Prepares a LanguageService object - */ - protected function fakeLanguageService(): void - { - /** @var $languageService \TYPO3\CMS\Core\Localization\LanguageService */ - $languageService = GeneralUtility::makeInstance(LanguageService::class); - $GLOBALS['LANG'] = $languageService; - } - /** * Triggers event queue processing */ diff --git a/Tests/Integration/IndexQueue/IndexerTest.php b/Tests/Integration/IndexQueue/IndexerTest.php index 921cdd3f17..471f53d954 100644 --- a/Tests/Integration/IndexQueue/IndexerTest.php +++ b/Tests/Integration/IndexQueue/IndexerTest.php @@ -15,24 +15,36 @@ namespace ApacheSolrForTypo3\Solr\Tests\Integration\IndexQueue; +use ApacheSolrForTypo3\Solr\FrontendEnvironment\Exception\Exception as FrontendEnvironmentException; use ApacheSolrForTypo3\Solr\IndexQueue\AdditionalIndexQueueItemIndexer; use ApacheSolrForTypo3\Solr\IndexQueue\Indexer; use ApacheSolrForTypo3\Solr\IndexQueue\Item; use ApacheSolrForTypo3\Solr\IndexQueue\Queue; +use ApacheSolrForTypo3\Solr\NoSolrConnectionFoundException; use ApacheSolrForTypo3\Solr\System\Solr\Document\Document; use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection; use ApacheSolrForTypo3\Solr\Tests\Integration\IndexQueue\Helpers\DummyAdditionalIndexQueueItemIndexer; use ApacheSolrForTypo3\Solr\Tests\Integration\IndexQueue\Helpers\DummyIndexer; use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\ConnectionException as DBALConnectionException; +use Doctrine\DBAL\Driver\Exception as DBALDriverException; +use Doctrine\DBAL\Exception as DBALException; +use Doctrine\DBAL\Schema\SchemaException; +use InvalidArgumentException; use Psr\Http\Server\RequestHandlerInterface; +use ReflectionException; +use Throwable; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException; +use TYPO3\CMS\Core\Database\Schema\Exception\StatementException; +use TYPO3\CMS\Core\Database\Schema\Exception\UnexpectedSignalReturnValueTypeException; +use TYPO3\CMS\Core\Exception\SiteNotFoundException; use TYPO3\CMS\Core\Http\ServerRequestFactory; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Middleware\NormalizedParamsAttribute; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Exception as TestingFrameworkCoreException; +use UnexpectedValueException; /** * Testcase for the record indexer @@ -44,18 +56,17 @@ class IndexerTest extends IntegrationTest protected bool $skipImportRootPagesAndTemplatesForConfiguredSites = true; /** - * @var Queue + * @var Queue|null */ - protected $indexQueue; + protected ?Queue $indexQueue = null; /** - * @var Indexer + * @var Indexer|null */ - protected $indexer; + protected ?Indexer $indexer = null; /** * @throws TestingFrameworkCoreException - * @throws DBALException * @throws NoSuchCacheException */ protected function setUp(): void @@ -68,10 +79,7 @@ protected function setUp(): void /* @var BackendUserAuthentication $beUser */ $beUser = GeneralUtility::makeInstance(BackendUserAuthentication::class); $GLOBALS['BE_USER'] = $beUser; - - /* @var LanguageService $languageService */ - $languageService = GeneralUtility::makeInstance(LanguageService::class); - $GLOBALS['LANG'] = $languageService; + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $_SERVER['HTTP_HOST'] = 'test.local.typo3.org'; $request = ServerRequestFactory::fromGlobals(); @@ -84,15 +92,30 @@ protected function tearDown(): void { parent::tearDown(); $this->cleanUpSolrServerAndAssertEmpty(); - unset($this->indexQueue, $this->indexer); + unset( + $this->indexQueue, + $this->indexer, + ); } /** - * This testcase should check if we can queue an custom record with MM relations. + * This testcase should check if we can queue a custom record with MM relations. * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexItemWithMMRelation() + public function canIndexItemWithMMRelation(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -122,19 +145,33 @@ public function canIndexItemWithMMRelation() public function getTranslatedRecordDataProvider(): array { return [ - 'with_l_paramater' => ['can_index_custom_translated_record_with_l_param.xml'], - 'without_l_paramater' => ['can_index_custom_translated_record_without_l_param.xml'], - 'without_l_paramater_and_content_fallback' => ['can_index_custom_translated_record_without_l_param_and_content_fallback.xml'], + 'with_l_parameter' => ['can_index_custom_translated_record_with_l_param.xml'], + 'without_l_parameter' => ['can_index_custom_translated_record_without_l_param.xml'], + 'without_l_parameter_and_content_fallback' => ['can_index_custom_translated_record_without_l_param_and_content_fallback.xml'], ]; } /** * @dataProvider getTranslatedRecordDataProvider * @test + * + * @param $fixture + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function testCanIndexTranslatedCustomRecord($fixture) + public function testCanIndexTranslatedCustomRecord($fixture): void { - $this->cleanUpSolrServerAndAssertEmpty('core_en'); + $this->cleanUpSolrServerAndAssertEmpty(); $this->cleanUpSolrServerAndAssertEmpty('core_de'); // create fake extension database table and TCA @@ -150,7 +187,7 @@ public function testCanIndexTranslatedCustomRecord($fixture) self::assertTrue($result, 'Indexing was not indicated to be successful'); // do we have the record in the index with the value from the mm relation? - $this->waitToBeVisibleInSolr('core_en'); + $this->waitToBeVisibleInSolr(); $solrContent = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/core_en/select?q=*:*'); self::assertStringContainsString('"numFound":2', $solrContent, 'Could not index document into solr'); self::assertStringContainsString('"title":"original"', $solrContent, 'Could not index document into solr'); @@ -171,16 +208,28 @@ public function testCanIndexTranslatedCustomRecord($fixture) self::assertStringContainsString('"url":"http://testone.site/de/?tx_foo%5Buid%5D=88', $solrContent, 'Can not build typolink as expected'); self::assertStringContainsString('"url":"http://testone.site/de/?tx_foo%5Buid%5D=777', $solrContent, 'Can not build typolink as expected'); - $this->cleanUpSolrServerAndAssertEmpty('core_en'); + $this->cleanUpSolrServerAndAssertEmpty(); $this->cleanUpSolrServerAndAssertEmpty('core_de'); } /** - * This testcase should check if we can queue an custom record with ordered MM relations. + * This testcase should check if we can queue a custom record with ordered MM relations. * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexItemWithMMRelationsInTheExpectedOrder() + public function canIndexItemWithMMRelationsInTheExpectedOrder(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -215,13 +264,25 @@ public function canIndexItemWithMMRelationsInTheExpectedOrder() } /** - * This testcase should check if we can queue an custom record with MM relations. + * This testcase should check if we can queue a custom record with MM relations. * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexTranslatedItemWithMMRelation() + public function canIndexTranslatedItemWithMMRelation(): void { - $this->cleanUpSolrServerAndAssertEmpty('core_en'); + $this->cleanUpSolrServerAndAssertEmpty(); $this->cleanUpSolrServerAndAssertEmpty('core_de'); // create fake extension database table and TCA @@ -241,20 +302,30 @@ public function canIndexTranslatedItemWithMMRelation() self::assertStringContainsString('"numFound":1', $solrContent, 'Could not index document into solr'); self::assertStringContainsString('"title":"translation"', $solrContent, 'Could not index document into solr'); - $this->cleanUpSolrServerAndAssertEmpty('core_en'); + $this->cleanUpSolrServerAndAssertEmpty(); $this->cleanUpSolrServerAndAssertEmpty('core_de'); } /** - * This testcase should check if we can queue an custom record with multiple MM relations. + * This testcase should check if we can queue a custom record with multiple MM relations. * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexMultipleMMRelatedItems() + public function canIndexMultipleMMRelatedItems(): void { - $this->cleanUpSolrServerAndAssertEmpty('core_en'); - -// $this->writeDefaultSolrTestSiteConfiguration(); + $this->cleanUpSolrServerAndAssertEmpty(); // create fake extension database table and TCA $this->importExtTablesDefinition('fake_extension2_table.sql'); @@ -266,26 +337,37 @@ public function canIndexMultipleMMRelatedItems() self::assertTrue($result, 'Indexing was not indicated to be successful'); // do we have the record in the index with the value from the mm relation? - $this->waitToBeVisibleInSolr('core_en'); + $this->waitToBeVisibleInSolr(); $solrContent = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/core_en/select?q=*:*'); $decodedSolrContent = json_decode($solrContent); - // @extensionScannerIgnoreLine $tags = $decodedSolrContent->response->docs[0]->tags_stringM; - self::assertSame(['the tag', 'another tag'], $tags, $solrContent, 'Did not find MM related tags'); + self::assertSame(['the tag', 'another tag'], $tags, 'Did not find MM related tags'); self::assertStringContainsString('"numFound":1', $solrContent, 'Could not index document into solr'); self::assertStringContainsString('"title":"testnews"', $solrContent, 'Could not index document into solr'); - $this->cleanUpSolrServerAndAssertEmpty('core_en'); + $this->cleanUpSolrServerAndAssertEmpty(); } /** - * This testcase should check if we can queue an custom record with MM relations and respect the additionalWhere clause. + * This testcase should check if we can queue a custom record with MM relations and respect the additionalWhere clause. * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexItemWithMMRelationAndAdditionalWhere() + public function canIndexItemWithMMRelationAndAdditionalWhere(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -312,10 +394,22 @@ public function canIndexItemWithMMRelationAndAdditionalWhere() * This testcase should check if we can queue a custom record with MM relations and respect the additionalWhere clause. * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexItemWithMMRelationToATranslatedPage() + public function canIndexItemWithMMRelationToATranslatedPage(): void { - $this->cleanUpSolrServerAndAssertEmpty('core_en'); + $this->cleanUpSolrServerAndAssertEmpty(); $this->cleanUpSolrServerAndAssertEmpty('core_de'); // create fake extension database table and TCA @@ -327,7 +421,7 @@ public function canIndexItemWithMMRelationToATranslatedPage() self::assertTrue($result, 'Indexing was not indicated to be successful'); // do we have the record in the index with the value from the mm relation? - $this->waitToBeVisibleInSolr('core_en'); + $this->waitToBeVisibleInSolr(); $this->waitToBeVisibleInSolr('core_de'); $solrContentEn = file_get_contents($this->getSolrConnectionUriAuthority() . '/solr/core_en/select?q=*:*'); @@ -336,7 +430,7 @@ public function canIndexItemWithMMRelationToATranslatedPage() self::assertStringContainsString('"relatedPageTitles_stringM":["Related page"]', $solrContentEn, 'Can not find related page title'); self::assertStringContainsString('"relatedPageTitles_stringM":["Translated related page"]', $solrContentDe, 'Can not find translated related page title'); - $this->cleanUpSolrServerAndAssertEmpty('core_en'); + $this->cleanUpSolrServerAndAssertEmpty(); $this->cleanUpSolrServerAndAssertEmpty('core_de'); } @@ -344,8 +438,20 @@ public function canIndexItemWithMMRelationToATranslatedPage() * This testcase is used to check if direct relations can be resolved with the RELATION configuration * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexItemWithDirectRelation() + public function canIndexItemWithDirectRelation(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -375,8 +481,20 @@ public function canIndexItemWithDirectRelation() * This testcase is used to check if multiple direct relations can be resolved with the RELATION configuration * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexItemWithMultipleDirectRelation() + public function canIndexItemWithMultipleDirectRelation(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -418,8 +536,20 @@ public function canIndexItemWithMultipleDirectRelation() * and could be limited with an additionalWhere clause at the same time * * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canIndexItemWithDirectRelationAndAdditionalWhere() + public function canIndexItemWithDirectRelationAndAdditionalWhere(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -444,8 +574,20 @@ public function canIndexItemWithDirectRelationAndAdditionalWhere() /** * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function canUseConfigurationFromTemplateInRootLine() + public function canUseConfigurationFromTemplateInRootLine(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -470,10 +612,12 @@ public function canUseConfigurationFromTemplateInRootLine() /** * @test + * + * @throws ReflectionException */ - public function canGetAdditionalDocumentsInterfaceOnly() + public function canGetAdditionalDocumentsInterfaceOnly(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments'][] = AdditionalIndexQueueItemIndexer::class; $document = new Document(); $metaData = ['item_type' => 'pages']; @@ -484,10 +628,11 @@ public function canGetAdditionalDocumentsInterfaceOnly() /** * @test + * @throws ReflectionException */ - public function canGetAdditionalDocumentsNotImplementingInterface() + public function canGetAdditionalDocumentsNotImplementingInterface(): void { - $this->expectException(\UnexpectedValueException::class); + $this->expectException(UnexpectedValueException::class); $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments'][] = DummyIndexer::class; $document = new Document(); $metaData = ['item_type' => 'pages']; @@ -498,23 +643,27 @@ public function canGetAdditionalDocumentsNotImplementingInterface() /** * @test + * + * @throws ReflectionException */ - public function canGetAdditionalDocumentsNonExistingClass() + public function canGetAdditionalDocumentsNonExistingClass(): void { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments'][] = 'NonExistingClass'; $document = new Document(); $metaData = ['item_type' => 'pages']; $record = []; $item = GeneralUtility::makeInstance(Item::class, $metaData, $record); - $result = $this->callInaccessibleMethod($this->indexer, 'getAdditionalDocuments', $item, 0, $document); + $this->callInaccessibleMethod($this->indexer, 'getAdditionalDocuments', $item, 0, $document); } /** * @test + * + * @throws ReflectionException */ - public function canGetAdditionalDocuments() + public function canGetAdditionalDocuments(): void { $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments'][] = DummyAdditionalIndexQueueItemIndexer::class; $document = new Document(); @@ -528,8 +677,20 @@ public function canGetAdditionalDocuments() /** * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function testCanIndexCustomRecordOutsideOfSiteRoot() + public function testCanIndexCustomRecordOutsideOfSiteRoot(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -554,8 +715,20 @@ public function testCanIndexCustomRecordOutsideOfSiteRoot() /** * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SchemaException + * @throws SiteNotFoundException + * @throws StatementException + * @throws TestingFrameworkCoreException + * @throws Throwable + * @throws UnexpectedSignalReturnValueTypeException */ - public function testCanIndexCustomRecordOutsideOfSiteRootWithTemplate() + public function testCanIndexCustomRecordOutsideOfSiteRootWithTemplate(): void { $this->cleanUpSolrServerAndAssertEmpty(); @@ -583,7 +756,16 @@ public function testCanIndexCustomRecordOutsideOfSiteRootWithTemplate() /** * @param string $table * @param int $uid + * * @return bool + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SiteNotFoundException + * @throws Throwable */ protected function addToQueueAndIndexRecord(string $table, int $uid): bool { @@ -602,8 +784,11 @@ protected function addToQueueAndIndexRecord(string $table, int $uid): bool /** * @test + * + * @throws ReflectionException + * @throws TestingFrameworkCoreException */ - public function getSolrConnectionsByItemReturnsNoDefaultConnectionIfRootPageIsHideDefaultLanguage() + public function getSolrConnectionsByItemReturnsNoDefaultConnectionIfRootPageIsHideDefaultLanguage(): void { $this->importDataSetFromFixture('can_index_with_rootPage_set_to_hide_default_language.xml'); $itemMetaData = [ @@ -625,8 +810,11 @@ public function getSolrConnectionsByItemReturnsNoDefaultConnectionIfRootPageIsHi /** * @test + * + * @throws ReflectionException + * @throws TestingFrameworkCoreException */ - public function getSolrConnectionsByItemReturnsNoDefaultConnectionDefaultLanguageIsHiddenInSiteConfig() + public function getSolrConnectionsByItemReturnsNoDefaultConnectionDefaultLanguageIsHiddenInSiteConfig(): void { $this->writeDefaultSolrTestSiteConfigurationForHostAndPort('http', 'localhost', 8999, true); $this->importDataSetFromFixture('can_index_with_rootPage_set_to_hide_default_language.xml'); @@ -650,8 +838,17 @@ public function getSolrConnectionsByItemReturnsNoDefaultConnectionDefaultLanguag /** * @test + * + * @throws DBALConnectionException + * @throws DBALDriverException + * @throws DBALException + * @throws FrontendEnvironmentException + * @throws NoSolrConnectionFoundException + * @throws SiteNotFoundException + * @throws TestingFrameworkCoreException + * @throws Throwable */ - public function getSolrConnectionsByItemReturnsProperItemInNestedSite() + public function getSolrConnectionsByItemReturnsProperItemInNestedSite(): void { $this->cleanUpSolrServerAndAssertEmpty(); $this->writeDefaultSolrTestSiteConfigurationForHostAndPort(); diff --git a/Tests/Integration/IntegrationTest.php b/Tests/Integration/IntegrationTest.php index e9eebe84c9..102dccb790 100644 --- a/Tests/Integration/IntegrationTest.php +++ b/Tests/Integration/IntegrationTest.php @@ -39,13 +39,14 @@ use TYPO3\CMS\Core\Database\Schema\SchemaMigrator; use TYPO3\CMS\Core\Database\Schema\SqlReader; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Error\Http\AbstractServerErrorException; use TYPO3\CMS\Core\Error\Http\InternalServerErrorException; use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException; use TYPO3\CMS\Core\Exception\SiteNotFoundException; use TYPO3\CMS\Core\Http\NormalizedParams; use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait; use TYPO3\CMS\Core\TimeTracker\TimeTracker; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -136,6 +137,7 @@ protected function setUp(): void * Loads a Fixture from the Fixtures folder beside the current test case. * * @param $fixtureName + * * @throws TestingFrameworkCoreException */ protected function importDataSetFromFixture($fixtureName) @@ -157,6 +159,7 @@ protected function getFixtureRootPath(): string * Returns the absolute path to a fixture file. * * @param $fixtureName + * * @return string */ protected function getFixturePathByName($fixtureName): string @@ -168,6 +171,7 @@ protected function getFixturePathByName($fixtureName): string * Returns the content of a fixture file. * * @param string $fixtureName + * * @return string */ protected function getFixtureContentByName(string $fixtureName): string @@ -179,6 +183,7 @@ protected function getFixtureContentByName(string $fixtureName): string * Imports an ext_tables.sql definition as done by the install-tool. * * @param string $fixtureName + * * @throws DoctrineDBALException * @throws SchemaException * @throws StatementException @@ -222,6 +227,7 @@ protected function getRuntimeDirectory(): string /** * @param string $version + * * @return bool */ protected function getIsTYPO3VersionBelow(string $version): bool @@ -233,7 +239,10 @@ protected function getIsTYPO3VersionBelow(string $version): bool * @param int $id * @param string $MP * @param int $language + * * @return TypoScriptFrontendController + * + * @throws AbstractServerErrorException * @throws InternalServerErrorException * @throws ServiceUnavailableException * @throws SiteNotFoundException @@ -270,6 +279,7 @@ protected function cleanUpSolrServerAndAssertEmpty(?string $coreName = 'core_en' /** * @param string|null $coreName + * * @return array|false */ protected function waitToBeVisibleInSolr(?string $coreName = 'core_en'): array|false @@ -281,6 +291,7 @@ protected function waitToBeVisibleInSolr(?string $coreName = 'core_en'): array|f /** * @param string $coreName + * * @throws InvalidArgumentException */ protected function validateTestCoreName(string $coreName) @@ -314,6 +325,7 @@ protected function assertSolrContainsDocumentCount(int $documentCount) * @param array $importPageIds * @param array|null $feUserGroupArray * + * @throws AbstractServerErrorException * @throws AspectNotFoundException * @throws DBALDriverException * @throws DoctrineDBALException @@ -333,12 +345,13 @@ protected function indexPageIdsFromFixture(string $fixture, array $importPageIds * @param array $importPageIds * @param array|null $feUserGroupArray * + * @throws AbstractServerErrorException + * @throws AspectNotFoundException * @throws DBALDriverException * @throws DoctrineDBALException * @throws InternalServerErrorException * @throws ServiceUnavailableException * @throws SiteNotFoundException - * @throws AspectNotFoundException */ protected function indexPageIds(array $importPageIds, ?array $feUserGroupArray = [0]) { @@ -363,6 +376,7 @@ protected function indexPageIds(array $importPageIds, ?array $feUserGroupArray = /** * @param int $isAdmin * @param int $workspace + * * @return BackendUserAuthentication */ protected function fakeBEUser(int $isAdmin = 0, int $workspace = 0): BackendUserAuthentication @@ -379,7 +393,10 @@ protected function fakeBEUser(int $isAdmin = 0, int $workspace = 0): BackendUser /** * @param int $pageId * @param array $feUserGroupArray + * * @return TypoScriptFrontendController + * + * @throws AbstractServerErrorException * @throws InternalServerErrorException * @throws ServiceUnavailableException * @throws SiteNotFoundException @@ -461,7 +478,7 @@ protected function applyUsingErrorControllerForCMS9andAbove() */ protected function getDataHandler(): DataHandler { - $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); /* @retrun DataHandler */ return GeneralUtility::makeInstance(DataHandler::class); } @@ -494,6 +511,7 @@ protected function writeDefaultSolrTestSiteConfiguration() * @param string|null $host * @param int|null $port * @param bool|null $disableDefaultLanguage + * * @throws TestingFrameworkCoreException */ protected function writeDefaultSolrTestSiteConfigurationForHostAndPort( @@ -625,6 +643,7 @@ protected function getSolrConnectionUriAuthority(): string * * @param object $object * @param string $property + * * @return mixed */ protected function getInaccessiblePropertyFromObject(object $object, string $property): mixed @@ -649,7 +668,9 @@ protected function getInaccessiblePropertyFromObject(object $object, string $pro * * @param object $object The object to be invoked * @param string $name the name of the method to call + * * @return mixed + * * @throws ReflectionException */ protected function callInaccessibleMethod(object $object, string $name): mixed diff --git a/Tests/Integration/Task/ReIndexTaskTest.php b/Tests/Integration/Task/ReIndexTaskTest.php index 8f530983bd..baa402e82d 100644 --- a/Tests/Integration/Task/ReIndexTaskTest.php +++ b/Tests/Integration/Task/ReIndexTaskTest.php @@ -23,7 +23,7 @@ use Exception; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException; -use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -70,9 +70,7 @@ protected function setUp(): void $beUser = GeneralUtility::makeInstance(BackendUserAuthentication::class); $GLOBALS['BE_USER'] = $beUser; - /* @var LanguageService $languageService */ - $languageService = GeneralUtility::makeInstance(LanguageService::class); - $GLOBALS['LANG'] = $languageService; + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); } protected function assertEmptyIndexQueue()