diff --git a/bundle/Command/IndexPageContentCommand.php b/bundle/Command/IndexPageContentCommand.php index d316daca..16069534 100644 --- a/bundle/Command/IndexPageContentCommand.php +++ b/bundle/Command/IndexPageContentCommand.php @@ -6,7 +6,11 @@ use Ibexa\Contracts\Core\Persistence\Handler as PersistenceHandler; use Ibexa\Contracts\Core\Repository\ContentService; +use Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException; +use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; +use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException; use Ibexa\Contracts\Core\Repository\Values\Content\Content; +use Ibexa\Contracts\Core\Repository\Values\Content\ContentList; use Ibexa\Contracts\Core\Repository\Values\Content\Query; use Ibexa\Contracts\Core\Repository\Values\Filter\Filter; use Ibexa\Contracts\Core\Search\Handler as SearchHandler; @@ -16,9 +20,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Ibexa\Contracts\Core\Repository\Values\Content\ContentList; - use Symfony\Component\Console\Style\SymfonyStyle; + use function count; use function explode; @@ -57,14 +60,14 @@ protected function initialize(InputInterface $input, OutputInterface $output): v } /** - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException + * @throws NotFoundException + * @throws InvalidArgumentException + * @throws UnauthorizedException */ protected function execute(InputInterface $input, OutputInterface $output): int { foreach ($this->sitesConfig as $site => $siteConfig) { - $this->style->info("Indexing for site " . $site); + $this->style->info('Indexing for site ' . $site); $this->indexContent($output, $input, $siteConfig); } @@ -103,11 +106,10 @@ private function indexContent(OutputInterface $output, InputInterface $input, ar $output->writeln(''); $this->style->info('Finished.'); - } /** - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ private function getTotalCount(array $allowedContentTypes, array $contentIds): int { @@ -121,7 +123,7 @@ private function getTotalCount(array $allowedContentTypes, array $contentIds): i } /** - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException + * @throws InvalidArgumentException */ private function getChunk(int $limit, int $offset, array $allowedContentTypes, array $contentIds): ContentList { @@ -130,6 +132,7 @@ private function getChunk(int $limit, int $offset, array $allowedContentTypes, a ->withLimit($limit) ->withOffset($offset) ; + return $this->contentService->find($filter); } @@ -141,6 +144,7 @@ private function getFilter(array $allowedContentTypes, array $contentIds = []): if (count($contentIds) > 0) { $filter->andWithCriterion(new Query\Criterion\ContentId($contentIds)); } + return $filter; } diff --git a/bundle/DependencyInjection/Configuration.php b/bundle/DependencyInjection/Configuration.php index 90cd514f..ff931cbe 100644 --- a/bundle/DependencyInjection/Configuration.php +++ b/bundle/DependencyInjection/Configuration.php @@ -8,6 +8,9 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; +use function array_keys; +use function is_string; + class Configuration implements ConfigurationInterface { protected string $rootNodeName; @@ -83,6 +86,7 @@ private function addPageIndexingSection(ArrayNodeDefinition $nodeDefinition): vo return true; } } + return false; }; $nodeDefinition @@ -106,7 +110,7 @@ private function addPageIndexingSection(ArrayNodeDefinition $nodeDefinition): vo ->children() ->integerNode('tree_root_location_id') ->info('Site root Location ID') - ->beforeNormalization()->always(static fn ($v) => is_string($v) ? (int)$v : $v)->end() + ->beforeNormalization()->always(static fn ($v) => is_string($v) ? (int) $v : $v)->end() ->end() ->arrayNode('languages_siteaccess_map') ->info('Language code mapped to page siteaccess') @@ -163,5 +167,4 @@ private function addPageIndexingSection(ArrayNodeDefinition $nodeDefinition): vo ->end() ->end(); } - } diff --git a/bundle/DependencyInjection/NetgenIbexaSearchExtraExtension.php b/bundle/DependencyInjection/NetgenIbexaSearchExtraExtension.php index ecb9ced5..fd99e893 100644 --- a/bundle/DependencyInjection/NetgenIbexaSearchExtraExtension.php +++ b/bundle/DependencyInjection/NetgenIbexaSearchExtraExtension.php @@ -10,9 +10,10 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; - use Symfony\Component\Yaml\Yaml; + use function array_key_exists; +use function file_get_contents; class NetgenIbexaSearchExtraExtension extends Extension implements PrependExtensionInterface { @@ -21,8 +22,9 @@ class NetgenIbexaSearchExtraExtension extends Extension implements PrependExtens 'languages_siteaccess_map' => [], 'host' => null, 'fields' => [], - 'allowed_content_types' => [] + 'allowed_content_types' => [], ]; + public function getAlias(): string { return 'netgen_ibexa_search_extra'; diff --git a/lib/Container/Compiler/ElasticsearchExtensibleDocumentFactoryPass.php b/lib/Container/Compiler/ElasticsearchExtensibleDocumentFactoryPass.php index b9e91313..9b33994b 100644 --- a/lib/Container/Compiler/ElasticsearchExtensibleDocumentFactoryPass.php +++ b/lib/Container/Compiler/ElasticsearchExtensibleDocumentFactoryPass.php @@ -5,6 +5,7 @@ namespace Netgen\IbexaSearchExtra\Container\Compiler; use Ibexa\Contracts\Core\Persistence\Content\Handler; +use Ibexa\Elasticsearch\DocumentMapper\DocumentFactoryInterface; use Netgen\IbexaSearchExtra\Core\Search\Elasticsearch\DocumentMapper\DocumentFactory; use Netgen\IbexaSearchExtra\Core\Search\Elasticsearch\Query\CriterionVisitor\Content\VisibilityVisitor as ContentVisibilityVisitor; use Netgen\IbexaSearchExtra\Core\Search\Elasticsearch\Query\CriterionVisitor\Location\VisibilityVisitor as LocationVisibilityVisitor; @@ -12,8 +13,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; -use Ibexa\Elasticsearch\DocumentMapper\DocumentFactoryInterface; + use function array_keys; +use function sprintf; /** * This compiler pass will register elastic search field mappers. @@ -40,29 +42,8 @@ public function process(ContainerBuilder $container): void ->addTag('ibexa.search.elasticsearch.query.location.criterion.visitor'); } - private function processVisitors(ContainerBuilder $container, string $name): void - { - if (!$container->hasDefinition(sprintf('netgen.ibexa_search_extra.elasticsearch.field_mapper.%s.aggregate', $name))) { - return; - } - - $aggregateDefinition = $container->getDefinition( - sprintf('netgen.ibexa_search_extra.elasticsearch.field_mapper.%s.aggregate', $name), - ); - - $this->registerMappers($aggregateDefinition, $container->findTaggedServiceIds(sprintf('netgen.ibexa_search_extra.elasticsearch.field_mapper.%s', $name))); - } - - private function registerMappers(Definition $definition, array $mapperIds): void - { - foreach (array_keys($mapperIds) as $id) { - $definition->addMethodCall('addMapper', [new Reference($id)]); - } - } - /** * @param ContainerBuilder $container - * @return void */ public function processDocumentFactory(ContainerBuilder $container): void { @@ -80,4 +61,24 @@ public function processDocumentFactory(ContainerBuilder $container): void new Reference('netgen.ibexa_search_extra.elasticsearch.field_mapper.block_translation.aggregate'), ]); } + + private function processVisitors(ContainerBuilder $container, string $name): void + { + if (!$container->hasDefinition(sprintf('netgen.ibexa_search_extra.elasticsearch.field_mapper.%s.aggregate', $name))) { + return; + } + + $aggregateDefinition = $container->getDefinition( + sprintf('netgen.ibexa_search_extra.elasticsearch.field_mapper.%s.aggregate', $name), + ); + + $this->registerMappers($aggregateDefinition, $container->findTaggedServiceIds(sprintf('netgen.ibexa_search_extra.elasticsearch.field_mapper.%s', $name))); + } + + private function registerMappers(Definition $definition, array $mapperIds): void + { + foreach (array_keys($mapperIds) as $id) { + $definition->addMethodCall('addMapper', [new Reference($id)]); + } + } } diff --git a/lib/Container/Compiler/PageIndexingPass.php b/lib/Container/Compiler/PageIndexingPass.php index 00fd8798..23ea1975 100644 --- a/lib/Container/Compiler/PageIndexingPass.php +++ b/lib/Container/Compiler/PageIndexingPass.php @@ -1,17 +1,16 @@ getParameter( diff --git a/lib/Core/Search/Common/PageTextExtractor/NativePageTextExtractor.php b/lib/Core/Search/Common/PageTextExtractor/NativePageTextExtractor.php index 06a891ef..30e71974 100644 --- a/lib/Core/Search/Common/PageTextExtractor/NativePageTextExtractor.php +++ b/lib/Core/Search/Common/PageTextExtractor/NativePageTextExtractor.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler; use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException; +use Netgen\IbexaSearchExtra\Core\Search\Common\PageTextExtractor; use Netgen\IbexaSearchExtra\Core\Search\Common\SiteConfigResolver; use Netgen\IbexaSearchExtra\Exception\IndexPageUnavailableException; use Psr\Log\LoggerInterface; @@ -18,6 +19,7 @@ use Symfony\Component\HttpClient\HttpClient; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\RouterInterface; + use function count; use function explode; use function in_array; @@ -27,11 +29,12 @@ use function mb_substr; use function sprintf; use function trim; + use const XML_ELEMENT_NODE; use const XML_HTML_DOCUMENT_NODE; use const XML_TEXT_NODE; -class NativePageTextExtractor extends \Netgen\IbexaSearchExtra\Core\Search\Common\PageTextExtractor +class NativePageTextExtractor extends PageTextExtractor { /** @var array|string>>> */ private array $cache = []; @@ -88,9 +91,9 @@ public function extractPageText(int $contentId, string $languageCode): array * @param string $languageCode * @param int $contentId * - * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException - * * @return string + * + * @throws NotFoundException */ private function generateUrl(string $languageCode, int $contentId, array $siteConfig): string { @@ -118,7 +121,6 @@ private function generateUrl(string $languageCode, int $contentId, array $siteCo ], UrlGeneratorInterface::ABSOLUTE_URL, ); - } private function resolveSiteAccess(ContentInfo $contentInfo, string $languageCode): string @@ -128,18 +130,17 @@ private function resolveSiteAccess(ContentInfo $contentInfo, string $languageCod if (!isset($siteConfig['languages_siteaccess_map'][$languageCode])) { throw new RuntimeException( sprintf( - "Language not supported for matched siteaccess group %s", - $siteConfig['site'] - ) + 'Language not supported for matched siteaccess group %s', + $siteConfig['site'], + ), ); } return $siteConfig['languages_siteaccess_map'][$languageCode]; - } /** - * @param \DOMNode $node + * @param DOMNode $node * @param array> $textArray * * @return array> @@ -158,7 +159,6 @@ private function recursiveExtractTextArray(DOMNode $node, array &$textArray, int foreach ($node->childNodes as $childNode) { $this->recursiveExtractTextArray($childNode, $textArray, $contentId); } - } if ($node->nodeType === XML_TEXT_NODE) { $textContent = trim($node->textContent); @@ -207,7 +207,7 @@ private function hasClass(DOMNode $node, string $className): bool /** * @throws NotFoundException * @throws UnauthorizedException - * @throws \RuntimeException + * @throws RuntimeException */ private function fetchPageSource(int $contentId, string $languageCode, array $siteConfig): string { @@ -218,7 +218,7 @@ private function fetchPageSource(int $contentId, string $languageCode, array $si $response = $httpClient->request( 'GET', - $url + $url, ); $html = $response->getContent(); diff --git a/lib/Core/Search/Common/SiteConfigResolver.php b/lib/Core/Search/Common/SiteConfigResolver.php index aa841f78..af9023cf 100644 --- a/lib/Core/Search/Common/SiteConfigResolver.php +++ b/lib/Core/Search/Common/SiteConfigResolver.php @@ -1,5 +1,7 @@ $sitesConfig */ @@ -17,8 +22,7 @@ public function __construct( private readonly ContentHandler $contentHandler, private readonly LocationHandler $locationHandler, private readonly array $sitesConfig - ) { - } + ) {} public function getSiteConfigForContent(int $contentId): array { @@ -38,19 +42,19 @@ public function getSiteConfigForContent(int $contentId): array $pathString = $location->pathString; $pathArray = explode('/', $pathString); - foreach ($this->sitesConfig as $site => $siteConfig) { + foreach ($this->sitesConfig as $site => $siteConfig) { if (in_array($siteConfig['tree_root_location_id'], $pathArray, false)) { - $siteConfig['site'] = $site; + $siteConfig['site'] = $site; + return $siteConfig; } } throw new RuntimeException( sprintf( - "Failed to match content ID %d to a siteaccess", - $contentInfo->id - ) + 'Failed to match content ID %d to a siteaccess', + $contentInfo->id, + ), ); - } } diff --git a/lib/Core/Search/Elasticsearch/DocumentMapper/BlockFieldMapper.php b/lib/Core/Search/Elasticsearch/DocumentMapper/BlockFieldMapper.php index 5197b4a9..88d829b1 100644 --- a/lib/Core/Search/Elasticsearch/DocumentMapper/BlockFieldMapper.php +++ b/lib/Core/Search/Elasticsearch/DocumentMapper/BlockFieldMapper.php @@ -1,5 +1,7 @@ mappers as $mapper) { diff --git a/lib/Core/Search/Elasticsearch/DocumentMapper/BlockTranslationFieldMapper.php b/lib/Core/Search/Elasticsearch/DocumentMapper/BlockTranslationFieldMapper.php index e92135fa..c55e4295 100644 --- a/lib/Core/Search/Elasticsearch/DocumentMapper/BlockTranslationFieldMapper.php +++ b/lib/Core/Search/Elasticsearch/DocumentMapper/BlockTranslationFieldMapper.php @@ -1,5 +1,7 @@ mappers as $mapper) { @@ -48,6 +49,7 @@ public function mapFields(SPIContent $content): array $fields = [...$fields, ...$mapper->mapFields($content)]; } } + return $fields; } } diff --git a/lib/Core/Search/Elasticsearch/DocumentMapper/ContentFieldMapper/ContentVisibilityFieldMapper.php b/lib/Core/Search/Elasticsearch/DocumentMapper/ContentFieldMapper/ContentVisibilityFieldMapper.php index e646c3b7..81689af1 100644 --- a/lib/Core/Search/Elasticsearch/DocumentMapper/ContentFieldMapper/ContentVisibilityFieldMapper.php +++ b/lib/Core/Search/Elasticsearch/DocumentMapper/ContentFieldMapper/ContentVisibilityFieldMapper.php @@ -1,5 +1,7 @@ versionInfo->contentInfo->isHidden, - new BooleanField(), - )]; + 'ng_content_visible', + !$content->versionInfo->contentInfo->isHidden, + new BooleanField(), + )]; } } diff --git a/lib/Core/Search/Elasticsearch/DocumentMapper/ContentTranslationFieldMapper.php b/lib/Core/Search/Elasticsearch/DocumentMapper/ContentTranslationFieldMapper.php index 25a669fb..c2197087 100644 --- a/lib/Core/Search/Elasticsearch/DocumentMapper/ContentTranslationFieldMapper.php +++ b/lib/Core/Search/Elasticsearch/DocumentMapper/ContentTranslationFieldMapper.php @@ -1,5 +1,7 @@ locationFieldMapper->mapFields($location); $locationTranslationDependentFields = $this->locationTranslationFieldMapper->mapFields($location, $document->languageCode); @@ -76,11 +75,10 @@ public function fromLocation(Location $location, ?Content $content = null): Iter ...$locationFields, ...$locationTranslationDependentFields, ...$blockFields, - ...$blockTranslationDependentFields + ...$blockTranslationDependentFields, ]; } return new ArrayIterator($documents); } - } diff --git a/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper.php b/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper.php index 091299e5..66c0cb46 100644 --- a/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper.php +++ b/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper.php @@ -1,10 +1,11 @@ mappers as $mapper) { diff --git a/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper/LocationVisibilityFieldMapper.php b/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper/LocationVisibilityFieldMapper.php index 0b0e870e..0a545b2b 100644 --- a/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper/LocationVisibilityFieldMapper.php +++ b/lib/Core/Search/Elasticsearch/DocumentMapper/LocationFieldMapper/LocationVisibilityFieldMapper.php @@ -1,9 +1,11 @@ contentHandler->load($location->contentId); + return [ new Field( 'ng_location_visible', !$location->hidden && !$location->invisible && !$content->versionInfo->contentInfo->isHidden, new BooleanField(), - ) + ), ]; } } diff --git a/lib/Core/Search/Elasticsearch/DocumentMapper/LocationTranslationFieldMapper.php b/lib/Core/Search/Elasticsearch/DocumentMapper/LocationTranslationFieldMapper.php index 10ac4cb5..8926f892 100644 --- a/lib/Core/Search/Elasticsearch/DocumentMapper/LocationTranslationFieldMapper.php +++ b/lib/Core/Search/Elasticsearch/DocumentMapper/LocationTranslationFieldMapper.php @@ -1,5 +1,7 @@ mappers as $mapper) { diff --git a/lib/Core/Search/Solr/FieldMapper/ContentTranslation/ContentPageTextFieldMapper.php b/lib/Core/Search/Solr/FieldMapper/ContentTranslation/ContentPageTextFieldMapper.php index 628f3361..28e3b791 100644 --- a/lib/Core/Search/Solr/FieldMapper/ContentTranslation/ContentPageTextFieldMapper.php +++ b/lib/Core/Search/Solr/FieldMapper/ContentTranslation/ContentPageTextFieldMapper.php @@ -1,5 +1,7 @@ setParameter('kernel.bundles', []); } - public function providerForIndexableFieldTypeDefaultConfiguration(): array + public function provideIndexableFieldTypeDefaultConfigurationCases(): iterable { return [ [ @@ -73,7 +72,7 @@ public function providerForIndexableFieldTypeDefaultConfiguration(): array } /** - * @dataProvider providerForIndexableFieldTypeDefaultConfiguration + * @dataProvider provideIndexableFieldTypeDefaultConfigurationCases */ public function testIndexableFieldTypeDefaultConfiguration(array $configuration): void { @@ -93,14 +92,13 @@ public function testIndexableFieldTypeDefaultConfiguration(array $configuration) ); } - - public function providerForPageIndexingConfiguration(): array + public function providePageIndexingConfigurationCases(): iterable { return [ [ [ 'page_indexing' => [ - 'enabled' => true + 'enabled' => true, ], ], null, @@ -117,8 +115,8 @@ public function providerForPageIndexingConfiguration(): array 'sites' => [ 'finaweb' => [ 'tree_root_location_id' => '42', - ] - ] + ], + ], ], ], 42, @@ -135,19 +133,19 @@ public function providerForPageIndexingConfiguration(): array 'sites' => [ 'finaweb' => [ 'languages_siteaccess_map' => [ - 'cro-HR' => 'fina_cro' + 'cro-HR' => 'fina_cro', ], - ] - ] + ], + ], ], ], null, [ - 'cro-HR' => 'fina_cro' + 'cro-HR' => 'fina_cro', ], null, [], - [] + [], ], [ @@ -156,16 +154,16 @@ public function providerForPageIndexingConfiguration(): array 'enabled' => true, 'sites' => [ 'finaweb' => [ - 'host' => 'string' - ] - ] + 'host' => 'string', + ], + ], ], ], null, [], 'string', [], - [] + [], ], [ @@ -177,11 +175,11 @@ public function providerForPageIndexingConfiguration(): array 'fields' => [ 'level1' => [ 'h1', - 'h2' - ] + 'h2', + ], ], - ] - ] + ], + ], ], ], null, @@ -190,10 +188,10 @@ public function providerForPageIndexingConfiguration(): array [ 'level1' => [ 'h1', - 'h2' - ] + 'h2', + ], ], - [] + [], ], [ @@ -204,11 +202,11 @@ public function providerForPageIndexingConfiguration(): array 'finaweb' => [ 'allowed_content_types' => [ 'ng_landing_page', - 'ng_frontpage' + 'ng_frontpage', ], - ] - ] - ] + ], + ], + ], ], null, [], @@ -216,8 +214,8 @@ public function providerForPageIndexingConfiguration(): array [], [ 'ng_landing_page', - 'ng_frontpage' - ] + 'ng_frontpage', + ], ], [ @@ -228,45 +226,44 @@ public function providerForPageIndexingConfiguration(): array 'finaweb' => [ 'tree_root_location_id' => '42', 'languages_siteaccess_map' => [ - 'cro-HR' => 'fina_cro' + 'cro-HR' => 'fina_cro', ], 'host' => 'string', 'fields' => [ 'level1' => [ 'h1', - 'h2' - ] + 'h2', + ], ], 'allowed_content_types' => [ 'ng_landing_page', - 'ng_frontpage' + 'ng_frontpage', ], - ] - ] + ], + ], ], ], 42, [ - 'cro-HR' => 'fina_cro' + 'cro-HR' => 'fina_cro', ], 'string', [ 'level1' => [ 'h1', - 'h2' - ] + 'h2', + ], ], [ 'ng_landing_page', - 'ng_frontpage' - ] + 'ng_frontpage', + ], ], ]; } - /** - * @dataProvider providerForPageIndexingConfiguration + * @dataProvider providePageIndexingConfigurationCases */ public function testPageIndexingConfiguration( array $configuration, @@ -282,41 +279,39 @@ public function testPageIndexingConfiguration( $sitesConfig = $this->container->getParameter('netgen_ibexa_search_extra.page_indexing.sites'); foreach ($sitesConfig as $site => $siteConfig) { - $this->assertArrayHasKey( + self::assertArrayHasKey( 'tree_root_location_id', $siteConfig, ); - $this->assertEquals($expectedTreeRootLocationId, $siteConfig['tree_root_location_id']); + self::assertEquals($expectedTreeRootLocationId, $siteConfig['tree_root_location_id']); - $this->assertArrayHasKey( + self::assertArrayHasKey( 'languages_siteaccess_map', $siteConfig, ); - $this->assertEquals($expectedLanguagesSiteaccessMap, $siteConfig['languages_siteaccess_map']); + self::assertEquals($expectedLanguagesSiteaccessMap, $siteConfig['languages_siteaccess_map']); - $this->assertArrayHasKey( + self::assertArrayHasKey( 'fields', $siteConfig, ); - $this->assertEquals($expectedFields, $siteConfig['fields']); + self::assertEquals($expectedFields, $siteConfig['fields']); - $this->assertArrayHasKey( + self::assertArrayHasKey( 'allowed_content_types', $siteConfig, ); - $this->assertEquals($expectedAllowedContentTypes, $siteConfig['allowed_content_types']); + self::assertEquals($expectedAllowedContentTypes, $siteConfig['allowed_content_types']); - $this->assertArrayHasKey( + self::assertArrayHasKey( 'host', $siteConfig, ); - $this->assertEquals($expectedHost, $siteConfig['host']); - + self::assertEquals($expectedHost, $siteConfig['host']); } } - - public function providerForPageIndexingDefaultConfigurationInvalidCases(): array + public function provideInvalidPageIndexingConfigurationCases(): iterable { return [ [ @@ -346,8 +341,8 @@ public function providerForPageIndexingDefaultConfigurationInvalidCases(): array 'page_indexing' => [ 'finaweb' => [ 'languages_siteaccess_map' => [ - 'cro-HR' => 5 - ] + 'cro-HR' => 5, + ], ], ], ], @@ -358,7 +353,7 @@ public function providerForPageIndexingDefaultConfigurationInvalidCases(): array [ 'page_indexing' => [ 'finaweb' => [ - 'host' => [] + 'host' => [], ], ], ], @@ -370,8 +365,8 @@ public function providerForPageIndexingDefaultConfigurationInvalidCases(): array 'page_indexing' => [ 'finaweb' => [ 'config' => [ - 'level1' => 'a' - ] + 'level1' => 'a', + ], ], ], ], @@ -383,13 +378,13 @@ public function providerForPageIndexingDefaultConfigurationInvalidCases(): array 'page_indexing' => [ 'finaweb' => [ 'config' => [ - ['h1', 'h2'] - ] + ['h1', 'h2'], + ], ], ], ], InvalidConfigurationException::class, - 'Array key (field importance level) must be of string type' + 'Array key (field importance level) must be of string type', ], [ [ @@ -397,20 +392,19 @@ public function providerForPageIndexingDefaultConfigurationInvalidCases(): array 'finaweb' => [ 'allowed_content_types' => [ 34, - 52 + 52, ], ], ], ], InvalidConfigurationException::class, - 'Expected "string", but got "int"' + 'Expected "string", but got "int"', ], ]; - } /** - * @dataProvider providerForPageIndexingDefaultConfigurationInvalidCases + * @dataProvider provideInvalidPageIndexingConfigurationCases */ public function testInvalidPageIndexingConfiguration(array $siteRootsConfig): void { @@ -418,8 +412,6 @@ public function testInvalidPageIndexingConfiguration(array $siteRootsConfig): vo $this->load($siteRootsConfig); } - - protected function getContainerExtensions(): array { return [ diff --git a/tests/lib/Integration/Implementation/Stubs/RouterStub.php b/tests/lib/Integration/Implementation/Stubs/RouterStub.php index 709c070c..64fada4d 100644 --- a/tests/lib/Integration/Implementation/Stubs/RouterStub.php +++ b/tests/lib/Integration/Implementation/Stubs/RouterStub.php @@ -4,35 +4,34 @@ namespace Netgen\IbexaSearchExtra\Tests\Integration\Implementation\Stubs; +use RuntimeException; use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RouterInterface; -use RuntimeException; - class RouterStub implements RouterInterface { public function setContext(RequestContext $context) { - throw new RuntimeException("Not implemented"); + throw new RuntimeException('Not implemented'); } public function getContext() { - throw new RuntimeException("Not implemented"); + throw new RuntimeException('Not implemented'); } public function getRouteCollection() { - throw new RuntimeException("Not implemented"); + throw new RuntimeException('Not implemented'); } public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH) { - throw new RuntimeException("Not implemented"); + throw new RuntimeException('Not implemented'); } public function match(string $pathinfo) { - throw new RuntimeException("Not implemented"); + throw new RuntimeException('Not implemented'); } -} \ No newline at end of file +}