diff --git a/.travis.yml b/.travis.yml index 4490198..811b8f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,9 @@ before_install: language: php php: + - 7.0 - 7.1 + - 7.2 env: global: diff --git a/Classes/Connection/Elasticsearch/IndexFactory.php b/Classes/Connection/Elasticsearch/IndexFactory.php index 66b448b..49956f0 100644 --- a/Classes/Connection/Elasticsearch/IndexFactory.php +++ b/Classes/Connection/Elasticsearch/IndexFactory.php @@ -39,6 +39,21 @@ class IndexFactory implements Singleton */ protected $configuration; + /** + * @var \TYPO3\CMS\Core\Log\Logger + */ + protected $logger; + + /** + * Inject log manager to get concrete logger from it. + * + * @param \TYPO3\CMS\Core\Log\LogManager $logManager + */ + public function injectLogger(\TYPO3\CMS\Core\Log\LogManager $logManager) + { + $this->logger = $logManager->getLogger(__CLASS__); + } + /** * @param ConfigurationContainerInterface $configuration */ @@ -60,7 +75,10 @@ class IndexFactory implements Singleton $index = $connection->getClient()->getIndex('typo3content'); if ($index->exists() === false) { - $index->create($this->getConfigurationFor($documentType)); + $config = $this->getConfigurationFor($documentType); + $this->logger->debug(sprintf('Create index %s.', $documentType), [$documentType, $config]); + $index->create($config); + $this->logger->debug(sprintf('Created index %s.', $documentType), [$documentType]); } return $index; @@ -76,9 +94,11 @@ class IndexFactory implements Singleton try { $configuration = $this->configuration->get('indexing.' . $documentType . '.index'); - if (isset($configuration['analysis']['analyzer'])) { - foreach ($configuration['analysis']['analyzer'] as $key => $analyzer) { - $configuration['analysis']['analyzer'][$key] = $this->prepareAnalyzerConfiguration($analyzer); + foreach (['analyzer', 'filter'] as $optionsToExpand) { + if (isset($configuration['analysis'][$optionsToExpand])) { + foreach ($configuration['analysis'][$optionsToExpand] as $key => $options) { + $configuration['analysis'][$optionsToExpand][$key] = $this->prepareOptions($options); + } } } @@ -89,20 +109,20 @@ class IndexFactory implements Singleton } /** - * @param array $analyzer + * @param array $options * * @return array */ - protected function prepareAnalyzerConfiguration(array $analyzer) + protected function prepareOptions(array $options) { - $fieldsToExplode = ['char_filter', 'filter']; + $fieldsToExplode = ['char_filter', 'filter', 'word_list']; foreach ($fieldsToExplode as $fieldToExplode) { - if (isset($analyzer[$fieldToExplode])) { - $analyzer[$fieldToExplode] = GeneralUtility::trimExplode(',', $analyzer[$fieldToExplode], true); + if (isset($options[$fieldToExplode])) { + $options[$fieldToExplode] = GeneralUtility::trimExplode(',', $options[$fieldToExplode], true); } } - return $analyzer; + return $options; } } diff --git a/Classes/DataProcessing/CopyToProcessor.php b/Classes/DataProcessing/CopyToProcessor.php index eea555f..2df7438 100644 --- a/Classes/DataProcessing/CopyToProcessor.php +++ b/Classes/DataProcessing/CopyToProcessor.php @@ -36,15 +36,19 @@ class CopyToProcessor implements ProcessorInterface return $record; } - protected function addArray(array &$target, array $from) + /** + * @param array &$to + * @param array $from + */ + protected function addArray(array &$to, array $from) { foreach ($from as $value) { if (is_array($value)) { - $this->addArray($target, $value); + $this->addArray($to, $value); continue; } - $target[] = (string) $value; + $to[] = (string) $value; } } } diff --git a/Classes/DataProcessing/ProcessorInterface.php b/Classes/DataProcessing/ProcessorInterface.php index 4dc0794..ef051f4 100644 --- a/Classes/DataProcessing/ProcessorInterface.php +++ b/Classes/DataProcessing/ProcessorInterface.php @@ -21,8 +21,8 @@ namespace Codappix\SearchCore\DataProcessing; */ /** - * All DataProcessing Processors should implement this interface, otherwise they - * will not be executed. + * All DataProcessing Processors should implement this interface, otherwise + * they will not be executed. */ interface ProcessorInterface { diff --git a/Classes/Domain/Index/IndexerFactory.php b/Classes/Domain/Index/IndexerFactory.php index dbae818..2dac06f 100644 --- a/Classes/Domain/Index/IndexerFactory.php +++ b/Classes/Domain/Index/IndexerFactory.php @@ -22,8 +22,6 @@ namespace Codappix\SearchCore\Domain\Index; use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\InvalidArgumentException; -use Codappix\SearchCore\Domain\Index\IndexerInterface; -use Codappix\SearchCore\Domain\Index\TcaIndexer; use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService; use TYPO3\CMS\Core\SingletonInterface as Singleton; use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; @@ -56,12 +54,9 @@ class IndexerFactory implements Singleton } /** - * @param string $identifier - * - * @return IndexerInterface * @throws NoMatchingIndexer */ - public function getIndexer($identifier) + public function getIndexer(string $identifier) : IndexerInterface { try { return $this->buildIndexer($this->configuration->get('indexing.' . $identifier . '.indexer'), $identifier); @@ -75,13 +70,9 @@ class IndexerFactory implements Singleton } /** - * @param string $indexerClass - * @param string $identifier - * - * @return IndexerInterface * @throws NoMatchingIndexer */ - protected function buildIndexer($indexerClass, $identifier) + protected function buildIndexer(string $indexerClass, string $identifier) : IndexerInterface { $indexer = null; if (is_subclass_of($indexerClass, TcaIndexer\PagesIndexer::class) diff --git a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php index b396b73..1c97f46 100644 --- a/Classes/Domain/Index/TcaIndexer/PagesIndexer.php +++ b/Classes/Domain/Index/TcaIndexer/PagesIndexer.php @@ -34,6 +34,12 @@ class PagesIndexer extends TcaIndexer */ protected $contentTableService; + /** + * @var \TYPO3\CMS\Core\Resource\FileRepository + * @inject + */ + protected $fileRepository; + /** * @param TcaTableService $tcaTableService * @param TcaTableService $tcaTableService @@ -52,9 +58,6 @@ class PagesIndexer extends TcaIndexer $this->configuration = $configuration; } - /** - * @param array &$record - */ protected function prepareRecord(array &$record) { $possibleTitleFields = ['nav_title', 'tx_tqseo_pagetitle_rel', 'title']; @@ -65,32 +68,62 @@ class PagesIndexer extends TcaIndexer } } - $record['content'] = $this->fetchContentForPage($record['uid']); + $record['media'] = $this->fetchMediaForPage($record['uid']); + $content = $this->fetchContentForPage($record['uid']); + if ($content !== []) { + $record['content'] = $content['content']; + $record['media'] = array_values(array_unique(array_merge($record['media'], $content['images']))); + } parent::prepareRecord($record); } - /** - * @param int $uid - * @return string - */ - protected function fetchContentForPage($uid) + protected function fetchContentForPage(int $uid) : array { $contentElements = $this->getQuery($this->contentTableService)->execute()->fetchAll(); - if ($contentElements === null) { $this->logger->debug('No content for page ' . $uid); - return ''; + return []; } $this->logger->debug('Fetched content for page ' . $uid); + $images = []; $content = []; foreach ($contentElements as $contentElement) { + $images = array_merge( + $images, + $this->getContentElementImages($contentElement['uid']) + ); $content[] = $contentElement['bodytext']; } - // Remove Tags. - // Interpret escaped new lines and special chars. - // Trim, e.g. trailing or leading new lines. - return trim(stripcslashes(strip_tags(implode(' ', $content)))); + return [ + // Remove Tags. + // Interpret escaped new lines and special chars. + // Trim, e.g. trailing or leading new lines. + 'content' => trim(stripcslashes(strip_tags(implode(' ', $content)))), + 'images' => $images, + ]; + } + + protected function getContentElementImages(int $uidOfContentElement) : array + { + return $this->fetchSysFileReferenceUids($uidOfContentElement, 'tt_content', 'image'); + } + + protected function fetchMediaForPage(int $uid) : array + { + return $this->fetchSysFileReferenceUids($uid, 'pages', 'media'); + } + + protected function fetchSysFileReferenceUids(int $uid, string $tablename, string $fieldname) : array + { + $imageRelationUids = []; + $imageRelations = $this->fileRepository->findByRelation($tablename, $fieldname, $uid); + + foreach ($imageRelations as $relation) { + $imageRelationUids[] = $relation->getUid(); + } + + return $imageRelationUids; } } diff --git a/Classes/Domain/Index/TcaIndexer/RelationResolver.php b/Classes/Domain/Index/TcaIndexer/RelationResolver.php index a2302ae..6af330e 100644 --- a/Classes/Domain/Index/TcaIndexer/RelationResolver.php +++ b/Classes/Domain/Index/TcaIndexer/RelationResolver.php @@ -33,7 +33,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; */ class RelationResolver implements Singleton { - public function resolveRelationsForRecord(TcaTableService $service, array &$record) : void + public function resolveRelationsForRecord(TcaTableService $service, array &$record) { foreach (array_keys($record) as $column) { // TODO: Define / configure fields to exclude?! @@ -97,7 +97,7 @@ class RelationResolver implements Singleton return array_map('trim', explode(',', $value)); } - protected function getUtilityForMode(): string + protected function getUtilityForMode() : string { if (TYPO3_MODE === 'BE') { return BackendUtility::class; diff --git a/Classes/Domain/Index/TcaIndexer/TcaTableService.php b/Classes/Domain/Index/TcaIndexer/TcaTableService.php index 7a322a0..7faac04 100644 --- a/Classes/Domain/Index/TcaIndexer/TcaTableService.php +++ b/Classes/Domain/Index/TcaIndexer/TcaTableService.php @@ -22,6 +22,7 @@ namespace Codappix\SearchCore\Domain\Index\TcaIndexer; use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\InvalidArgumentException as InvalidConfigurationArgumentException; +use Codappix\SearchCore\DataProcessing\ProcessorInterface; use Codappix\SearchCore\Database\Doctrine\Join; use Codappix\SearchCore\Database\Doctrine\Where; use Codappix\SearchCore\Domain\Index\IndexingException; @@ -125,11 +126,8 @@ class TcaTableService /** * Filter the given records by root line blacklist settings. - * - * @param array &$records - * @return void */ - public function filterRecordsByRootLineBlacklist(array &$records) : void + public function filterRecordsByRootLineBlacklist(array &$records) { $records = array_filter( $records, @@ -140,12 +138,23 @@ class TcaTableService } /** - * @param array &$record + * Adjust record accordingly to configuration. */ - public function prepareRecord(array &$record) : void + public function prepareRecord(array &$record) { $this->relationResolver->resolveRelationsForRecord($this, $record); + try { + foreach ($this->configuration->get('indexing.' . $this->tableName . '.dataProcessing') as $configuration) { + $dataProcessor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($configuration['_typoScriptNodeValue']); + if ($dataProcessor instanceof ProcessorInterface) { + $record = $dataProcessor->processRecord($record, $configuration); + } + } + } catch (InvalidConfigurationArgumentException $e) { + // Nothing to do. + } + if (isset($record['uid']) && !isset($record['search_identifier'])) { $record['search_identifier'] = $record['uid']; } @@ -229,11 +238,7 @@ class TcaTableService return $whereClause; } - /** - * @param string - * @return bool - */ - protected function isSystemField($columnName) : bool + protected function isSystemField(string $columnName) : bool { $systemFields = [ // Versioning fields, @@ -265,11 +270,9 @@ class TcaTableService } /** - * @param string $columnName - * @return array * @throws InvalidArgumentException */ - public function getColumnConfig($columnName) : array + public function getColumnConfig(string $columnName) : array { if (!isset($this->tca['columns'][$columnName])) { throw new InvalidArgumentException( @@ -288,9 +291,6 @@ class TcaTableService * Also further TYPO3 mechanics are taken into account. Does a valid root * line exist, is page inside a recycler, is inherited start- endtime * excluded, etc. - * - * @param array &$record - * @return bool */ protected function isRecordBlacklistedByRootline(array &$record) : bool { @@ -346,8 +346,6 @@ class TcaTableService /** * Checks whether any page uids are black listed. - * - * @return bool */ protected function isBlackListedRootLineConfigured() : bool { @@ -356,8 +354,6 @@ class TcaTableService /** * Get the list of black listed root line page uids. - * - * @return array */ protected function getBlackListedRootLine() : array { diff --git a/Classes/Domain/Search/QueryFactory.php b/Classes/Domain/Search/QueryFactory.php index 980b763..e193e64 100644 --- a/Classes/Domain/Search/QueryFactory.php +++ b/Classes/Domain/Search/QueryFactory.php @@ -23,7 +23,6 @@ namespace Codappix\SearchCore\Domain\Search; use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Configuration\ConfigurationUtility; use Codappix\SearchCore\Configuration\InvalidArgumentException; -use Codappix\SearchCore\Connection\ConnectionInterface; use Codappix\SearchCore\Connection\Elasticsearch\Query; use Codappix\SearchCore\Connection\SearchRequestInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -134,13 +133,15 @@ class QueryFactory ]; } - $query = ArrayUtility::arrayMergeRecursiveOverrule($query, [ - 'query' => [ - 'bool' => [ - 'should' => $boostQueryParts, + if (!empty($boostQueryParts)) { + $query = ArrayUtility::arrayMergeRecursiveOverrule($query, [ + 'query' => [ + 'bool' => [ + 'should' => $boostQueryParts, + ], ], - ], - ]); + ]); + } } protected function addFactorBoost(array &$query) diff --git a/Classes/Domain/Service/DataHandler.php b/Classes/Domain/Service/DataHandler.php index 6ac8069..4b0386e 100644 --- a/Classes/Domain/Service/DataHandler.php +++ b/Classes/Domain/Service/DataHandler.php @@ -23,7 +23,6 @@ namespace Codappix\SearchCore\Domain\Service; use Codappix\SearchCore\Configuration\ConfigurationContainerInterface; use Codappix\SearchCore\Domain\Index\IndexerFactory; use Codappix\SearchCore\Domain\Index\NoMatchingIndexerException; -use Codappix\SearchCore\Domain\Index\TcaIndexer; use TYPO3\CMS\Core\SingletonInterface as Singleton; use TYPO3\CMS\Core\Utility\GeneralUtility; diff --git a/Classes/Hook/DataHandler.php b/Classes/Hook/DataHandler.php index d0eb1ba..3c4902a 100644 --- a/Classes/Hook/DataHandler.php +++ b/Classes/Hook/DataHandler.php @@ -21,7 +21,6 @@ namespace Codappix\SearchCore\Hook; */ use Codappix\SearchCore\Configuration\NoConfigurationException; -use Codappix\SearchCore\Domain\Index\NoMatchingIndexerException; use Codappix\SearchCore\Domain\Service\DataHandler as OwnDataHandler; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\DataHandling\DataHandler as CoreDataHandler; diff --git a/Documentation/source/readme.rst b/Documentation/source/readme.rst index ba77ae8..cc516d1 100644 --- a/Documentation/source/readme.rst +++ b/Documentation/source/readme.rst @@ -28,4 +28,3 @@ We are also focusing on Code Quality and Testing through `travis ci`_, `scrutini .. _travis ci: https://travis-ci.org/Codappix/search_core .. _scrutinizer: https://scrutinizer-ci.com/g/Codappix/search_core/inspections .. _codacy: https://www.codacy.com/app/Codappix/search_core/dashboard - diff --git a/Makefile b/Makefile index b6bc72b..f8cb090 100644 --- a/Makefile +++ b/Makefile @@ -5,14 +5,14 @@ TYPO3_WEB_DIR := $(current_dir).Build/web TYPO3_PATH_ROOT := $(current_dir).Build/web # Allow different versions on travis TYPO3_VERSION ?= ~8.7 -typo3DatabaseName ?= "searchcore_test2" +typo3DatabaseName ?= "searchcore_test" typo3DatabaseUsername ?= "dev" typo3DatabasePassword ?= "dev" typo3DatabaseHost ?= "127.0.0.1" .PHONY: install install: clean - COMPOSER_PROCESS_TIMEOUT=1000 composer require -vv --dev --prefer-dist --ignore-platform-reqs typo3/cms="$(TYPO3_VERSION)" + COMPOSER_PROCESS_TIMEOUT=1000 composer require -vv --dev typo3/cms="$(TYPO3_VERSION)" git checkout composer.json functionalTests: diff --git a/Tests/Functional/Connection/Elasticsearch/FilterTest.php b/Tests/Functional/Connection/Elasticsearch/FilterTest.php index e364a4a..2430833 100644 --- a/Tests/Functional/Connection/Elasticsearch/FilterTest.php +++ b/Tests/Functional/Connection/Elasticsearch/FilterTest.php @@ -48,14 +48,14 @@ class FilterTest extends AbstractFunctionalTestCase $searchService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class) ->get(SearchService::class); - $searchRequest = new SearchRequest('Search Word'); + $searchRequest = new SearchRequest(); $result = $searchService->search($searchRequest); $this->assertSame(2, count($result), 'Did not receive both indexed elements without filter.'); $searchRequest->setFilter(['CType' => 'HTML']); $result = $searchService->search($searchRequest); - $this->assertSame(5, $result->getResults()[0]['uid'], 'Did not get the expected result entry.'); + $this->assertSame(5, (int) $result->getResults()[0]['uid'], 'Did not get the expected result entry.'); $this->assertSame(1, count($result), 'Did not receive the single filtered element.'); } @@ -73,7 +73,7 @@ class FilterTest extends AbstractFunctionalTestCase $searchService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class) ->get(SearchService::class); - $searchRequest = new SearchRequest('Search Word'); + $searchRequest = new SearchRequest(); $result = $searchService->search($searchRequest); $this->assertSame(1, count($result->getFacets()), 'Did not receive the single defined facet.'); diff --git a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php index b1e8191..30da13d 100644 --- a/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php +++ b/Tests/Functional/Connection/Elasticsearch/IndexTcaTableTest.php @@ -175,7 +175,7 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase ['_source' => [ 'uid' => '11', 'CType' => 'Header', // Testing items - 'categories' => ['Category 2', 'Category 1'], // Testing mm + 'categories' => ['Category 2', 'Category 1'], // Testing mm (with sorting) ]], $response->getData()['hits']['hits'][0], false, @@ -236,4 +236,33 @@ class IndexTcaTableTest extends AbstractFunctionalTestCase $response = $this->client->request('typo3content/_search?q=*:*'); $this->assertSame($response->getData()['hits']['total'], 1, 'Not exactly 1 document is in index.'); } + + /** + * @test + */ + public function indexPagesMedia() + { + \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class) + ->get(IndexerFactory::class) + ->getIndexer('pages') + ->indexAllDocuments() + ; + + $response = $this->client->request('typo3content/_search?q=*:*'); + + $this->assertTrue($response->isOK(), 'Elastica did not answer with ok code.'); + $this->assertSame($response->getData()['hits']['total'], 2, 'Not exactly 2 documents were indexed.'); + $this->assertArraySubset( + [ + '_source' => [ + 'media' => [ + 10, 1 + ] + ] + ], + $response->getData()['hits']['hits'][0], + false, + 'Record was not indexed.' + ); + } } diff --git a/Tests/Functional/Fixtures/BasicSetup.ts b/Tests/Functional/Fixtures/BasicSetup.ts index b7b0c6a..3551670 100644 --- a/Tests/Functional/Fixtures/BasicSetup.ts +++ b/Tests/Functional/Fixtures/BasicSetup.ts @@ -37,6 +37,7 @@ plugin { } searching { + fields = search_title facets { contentTypes { field = CType diff --git a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml index c236f07..aa2a8fa 100644 --- a/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml +++ b/Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml @@ -29,7 +29,7 @@ 72 header
endtime hidden record
- + Some content 0 0 0 @@ -49,7 +49,7 @@ 72 header
Hidden record
- + Some content 0 0 0 @@ -99,4 +99,71 @@ 0 0 + + + 2 + 1 + Example page with + Used as abstract as no abstract is defined. + 2 + + + + 1 + 1 + 1 + 2 + pages + media + 2 + sys_file + + + + + + 10 + 1 + 2 + 2 + pages + media + 1 + sys_file + + + + + + 1 + 0 + 1 + 2 + full/file/path.png + 94dd1f9645114cf1344438ac7188db972768f59f + 67887283a03f465f1004d1d43a157ee1f1c59be5 + png + image/png + path2.png + c1dd34eb34d651ee6ca6ac52dea595db75d8e9d2 + 3044 + 1432306303 + 1432306303 + + + 2 + 0 + 1 + 2 + full/file/path2.png + 94dd1f9645114cf1344438ac7188db972768f59f + 67887283a03f465f1004d1d43a157ee1f1c59be5 + png + image/png + path2.png + c1dd34eb34d651ee6ca6ac52dea595db75d8e9d2 + 3044 + 1432306303 + 1432306303 + diff --git a/Tests/Functional/Fixtures/Indexing/UserWhereClause.xml b/Tests/Functional/Fixtures/Indexing/UserWhereClause.xml index 12347ef..b9d9c7c 100644 --- a/Tests/Functional/Fixtures/Indexing/UserWhereClause.xml +++ b/Tests/Functional/Fixtures/Indexing/UserWhereClause.xml @@ -9,7 +9,7 @@ 72 header
Also indexable record
- + Some content 0 0 0 @@ -29,7 +29,7 @@ 72 div
Not indexed by user where ctype condition
- + Some content 0 0 0 diff --git a/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php b/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php index 6a027cf..6276616 100644 --- a/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php +++ b/Tests/Functional/Hooks/DataHandler/ProcessesAllowedTablesTest.php @@ -72,9 +72,9 @@ class ProcessesAllowedTablesTest extends AbstractDataHandlerTest ->with( $this->equalTo('tt_content'), $this->callback(function ($record) { - return isset($record['uid']) && $record['uid'] === 1 - && isset($record['pid']) && $record['pid'] === 1 - && isset($record['colPos']) && $record['colPos'] === 1 + return isset($record['uid']) && $record['uid'] == 1 + && isset($record['pid']) && $record['pid'] == 1 + && isset($record['colPos']) && $record['colPos'] == 1 ; }) ); @@ -100,9 +100,9 @@ class ProcessesAllowedTablesTest extends AbstractDataHandlerTest ->with( $this->equalTo('tt_content'), $this->callback(function ($record) { - return isset($record['uid']) && $record['uid'] === 2 - && isset($record['pid']) && $record['pid'] === 1 - && isset($record['header']) && $record['header'] === 'a new record' + return isset($record['uid']) && $record['uid'] == 2 + && isset($record['pid']) && $record['pid'] == 1 + && isset($record['header']) && $record['header'] == 'a new record' ; }) ); diff --git a/Tests/Functional/Indexing/PagesIndexerTest.php b/Tests/Functional/Indexing/PagesIndexerTest.php index 244413d..bf5a35f 100644 --- a/Tests/Functional/Indexing/PagesIndexerTest.php +++ b/Tests/Functional/Indexing/PagesIndexerTest.php @@ -1,5 +1,5 @@ @@ -48,7 +48,7 @@ class PagesIndexerTest extends AbstractFunctionalTestCase ->with( $this->stringContains($tableName), $this->callback(function ($documents) { - return count($documents) === 1 + return count($documents) === 2 && isset($documents[0]['content']) && $documents[0]['content'] === 'this is the content of header content element that should get indexed Some text in paragraph' && isset($documents[0]['search_abstract']) && $documents[0]['search_abstract'] === diff --git a/Tests/Functional/Indexing/TcaIndexer/RelationResolverTest.php b/Tests/Functional/Indexing/TcaIndexer/RelationResolverTest.php index a491677..62c5158 100644 --- a/Tests/Functional/Indexing/TcaIndexer/RelationResolverTest.php +++ b/Tests/Functional/Indexing/TcaIndexer/RelationResolverTest.php @@ -1,5 +1,5 @@ diff --git a/Tests/Functional/Indexing/TcaIndexerTest.php b/Tests/Functional/Indexing/TcaIndexerTest.php index edf1a74..ff89318 100644 --- a/Tests/Functional/Indexing/TcaIndexerTest.php +++ b/Tests/Functional/Indexing/TcaIndexerTest.php @@ -1,5 +1,5 @@ diff --git a/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php b/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php index c73fe36..4ede3cb 100644 --- a/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php +++ b/Tests/Unit/Connection/Elasticsearch/IndexFactoryTest.php @@ -38,6 +38,7 @@ class IndexFactoryTest extends AbstractUnitTestCase $this->configuration = $this->getMockBuilder(ConfigurationContainerInterface::class)->getMock(); $this->subject = new IndexFactory($this->configuration); + $this->subject->injectLogger($this->getMockedLogger()); } /** diff --git a/Tests/Unit/Domain/Search/QueryFactoryTest.php b/Tests/Unit/Domain/Search/QueryFactoryTest.php index e0fc86d..cf74ce3 100644 --- a/Tests/Unit/Domain/Search/QueryFactoryTest.php +++ b/Tests/Unit/Domain/Search/QueryFactoryTest.php @@ -106,7 +106,7 @@ class QueryFactoryTest extends AbstractUnitTestCase $query = $this->subject->create($searchRequest); $this->assertSame( null, - $query->toArray()['query']['bool']['filter'], + $query->toArray()['query']['function_score']['query']['bool']['filter'], 'Filter was added to query, even if no filter exists.' ); } @@ -181,7 +181,7 @@ class QueryFactoryTest extends AbstractUnitTestCase 'type' => 'most_fields', 'query' => 'SearchWord', 'fields' => [ - '_all', + 0 => 'test_field', ], ], ], @@ -212,7 +212,7 @@ class QueryFactoryTest extends AbstractUnitTestCase $this->configureConfigurationMockWithDefault(); $query = $this->subject->create($searchRequest); - $this->assertArraySubset( + $this->assertSame( [ 'bool' => [ 'must' => [ @@ -221,7 +221,7 @@ class QueryFactoryTest extends AbstractUnitTestCase 'type' => 'most_fields', 'query' => 'SearchWord', 'fields' => [ - '_all', + 'test_field', ], 'minimum_should_match' => '50%', ], @@ -251,7 +251,7 @@ class QueryFactoryTest extends AbstractUnitTestCase ['searching.fieldValueFactor'] ) ->will($this->onConsecutiveCalls( - '_all', + 'test_field', [ 'search_title' => 3, 'search_abstract' => 1.5, @@ -308,7 +308,7 @@ class QueryFactoryTest extends AbstractUnitTestCase ['searching.fieldValueFactor'] ) ->will($this->onConsecutiveCalls( - '_all', + 'test_field', $this->throwException(new InvalidArgumentException), $this->throwException(new InvalidArgumentException), $this->throwException(new InvalidArgumentException), @@ -327,7 +327,7 @@ class QueryFactoryTest extends AbstractUnitTestCase 'type' => 'most_fields', 'query' => 'SearchWord', 'fields' => [ - '_all', + 0 => 'test_field', ], ], ], @@ -376,7 +376,7 @@ class QueryFactoryTest extends AbstractUnitTestCase ['searching.fieldValueFactor'] ) ->will($this->onConsecutiveCalls( - '_all, field1, field2', + 'test_field, field1, field2', $this->throwException(new InvalidArgumentException), $this->throwException(new InvalidArgumentException), $this->throwException(new InvalidArgumentException), @@ -393,7 +393,7 @@ class QueryFactoryTest extends AbstractUnitTestCase 'type' => 'most_fields', 'query' => 'SearchWord', 'fields' => [ - '_all', + 'test_field', 'field1', 'field2', ], @@ -483,7 +483,7 @@ class QueryFactoryTest extends AbstractUnitTestCase ['searching.fieldValueFactor'] ) ->will($this->onConsecutiveCalls( - '_all', + 'test_field', $this->throwException(new InvalidArgumentException), $this->throwException(new InvalidArgumentException), [ @@ -616,7 +616,7 @@ class QueryFactoryTest extends AbstractUnitTestCase ->method('get') ->will($this->returnCallback(function ($configName) { if ($configName === 'searching.fields.query') { - return '_all'; + return 'test_field'; } throw new InvalidArgumentException(); diff --git a/composer.json b/composer.json index b704e77..78f22d9 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require" : { - "php": ">=7.1.0", + "php": ">=7.0", "typo3/cms": "~8.7", "ruflin/elastica": "~3.2" }, diff --git a/ext_emconf.php b/ext_emconf.php index 4d342a5..a4cb46c 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ $EM_CONF[$_EXTKEY] = [ 'constraints' => [ 'depends' => [ 'typo3' => '8.7.0-8.7.99', - 'php' => '7.1.0-7.99.99' + 'php' => '7.0.0-7.99.99' ], 'conflicts' => [], ], diff --git a/ext_localconf.php b/ext_localconf.php index c52d05d..7743804 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -11,7 +11,7 @@ call_user_func( 'SC_OPTIONS' => [ 'extbase' => [ 'commandControllers' => [ - Codappix\SearchCore\Command\IndexCommandController::class, + $extensionKey . '::index' => Codappix\SearchCore\Command\IndexCommandController::class, ], ], 't3lib/class.t3lib_tcemain.php' => [