mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 15:56:11 +01:00
TASK: Add tests covering new pages indexing
Including content and search abstract.
This commit is contained in:
parent
d36d8e8594
commit
299ec3af5e
6 changed files with 137 additions and 8 deletions
|
@ -9,6 +9,15 @@ plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
indexing {
|
indexing {
|
||||||
|
# Not for direct indexing therefore no indexer.
|
||||||
|
# Used to configure tt_content fetching while indexing pages
|
||||||
|
tt_content {
|
||||||
|
additionalWhereClause (
|
||||||
|
tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu', 'shortcut', 'search', 'login')
|
||||||
|
AND tt_content.bodytext != ''
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
pages {
|
pages {
|
||||||
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer\PagesIndexer
|
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer\PagesIndexer
|
||||||
additionalWhereClause = {$plugin.tx_searchcore.settings.indexing.pages.additionalWhereClause}
|
additionalWhereClause = {$plugin.tx_searchcore.settings.indexing.pages.additionalWhereClause}
|
||||||
|
|
|
@ -12,6 +12,22 @@ plugin {
|
||||||
tt_content {
|
tt_content {
|
||||||
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer
|
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer
|
||||||
|
|
||||||
|
additionalWhereClause (
|
||||||
|
tt_content.CType NOT IN ('gridelements_pi1', 'list', 'div', 'menu', 'shortcut', 'search', 'login')
|
||||||
|
AND tt_content.bodytext != ''
|
||||||
|
)
|
||||||
|
|
||||||
|
mapping {
|
||||||
|
CType {
|
||||||
|
type = keyword
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pages {
|
||||||
|
indexer = Codappix\SearchCore\Domain\Index\TcaIndexer\PagesIndexer
|
||||||
|
abstractFields = abstract, description, bodytext
|
||||||
|
|
||||||
mapping {
|
mapping {
|
||||||
CType {
|
CType {
|
||||||
type = keyword
|
type = keyword
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
<uid>1</uid>
|
<uid>1</uid>
|
||||||
<pid>0</pid>
|
<pid>0</pid>
|
||||||
<title>Root page containing necessary TypoScript</title>
|
<title>Root page containing necessary TypoScript</title>
|
||||||
|
<description>Used as abstract as no abstract is defined.</description>
|
||||||
</pages>
|
</pages>
|
||||||
</dataset>
|
</dataset>
|
||||||
|
|
|
@ -60,4 +60,43 @@
|
||||||
<filelink_sorting>0</filelink_sorting>
|
<filelink_sorting>0</filelink_sorting>
|
||||||
</tt_content>
|
</tt_content>
|
||||||
|
|
||||||
|
<tt_content>
|
||||||
|
<uid>9</uid>
|
||||||
|
<pid>1</pid>
|
||||||
|
<tstamp>1480686370</tstamp>
|
||||||
|
<crdate>1480686370</crdate>
|
||||||
|
<hidden>0</hidden>
|
||||||
|
<sorting>72</sorting>
|
||||||
|
<CType>list</CType>
|
||||||
|
<header>not indexed due to ctype</header>
|
||||||
|
<bodytext>this is the content of header content element that should not get indexed</bodytext>
|
||||||
|
<media>0</media>
|
||||||
|
<layout>0</layout>
|
||||||
|
<deleted>0</deleted>
|
||||||
|
<cols>0</cols>
|
||||||
|
<starttime>0</starttime>
|
||||||
|
<endtime>0</endtime>
|
||||||
|
<colPos>0</colPos>
|
||||||
|
<filelink_sorting>0</filelink_sorting>
|
||||||
|
</tt_content>
|
||||||
|
|
||||||
|
<tt_content>
|
||||||
|
<uid>10</uid>
|
||||||
|
<pid>1</pid>
|
||||||
|
<tstamp>1480686370</tstamp>
|
||||||
|
<crdate>1480686370</crdate>
|
||||||
|
<hidden>0</hidden>
|
||||||
|
<sorting>72</sorting>
|
||||||
|
<CType>html</CType>
|
||||||
|
<header>Indexed without html tags</header>
|
||||||
|
<bodytext><![CDATA[<p>Some text in paragraph</p>]]></bodytext>
|
||||||
|
<media>0</media>
|
||||||
|
<layout>0</layout>
|
||||||
|
<deleted>0</deleted>
|
||||||
|
<cols>0</cols>
|
||||||
|
<starttime>0</starttime>
|
||||||
|
<endtime>0</endtime>
|
||||||
|
<colPos>0</colPos>
|
||||||
|
<filelink_sorting>0</filelink_sorting>
|
||||||
|
</tt_content>
|
||||||
</dataset>
|
</dataset>
|
||||||
|
|
64
Tests/Functional/Indexing/PagesIndexerTest.php
Normal file
64
Tests/Functional/Indexing/PagesIndexerTest.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
namespace Codappix\SearchCore\Tests\Indexing;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Codappix\SearchCore\Configuration\ConfigurationContainerInterface;
|
||||||
|
use Codappix\SearchCore\Connection\Elasticsearch;
|
||||||
|
use Codappix\SearchCore\Domain\Index\IndexerFactory;
|
||||||
|
use Codappix\SearchCore\Tests\Functional\AbstractFunctionalTestCase;
|
||||||
|
use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
|
|
||||||
|
class PagesIndexerTest extends AbstractFunctionalTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function pagesContainAllAdditionalInformation()
|
||||||
|
{
|
||||||
|
$this->importDataSet('Tests/Functional/Fixtures/Indexing/IndexTcaTable.xml');
|
||||||
|
|
||||||
|
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(ObjectManager::class);
|
||||||
|
$tableName = 'pages';
|
||||||
|
|
||||||
|
$connection = $this->getMockBuilder(Elasticsearch::class)
|
||||||
|
->setMethods(['addDocuments'])
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$connection->expects($this->once())
|
||||||
|
->method('addDocuments')
|
||||||
|
->with(
|
||||||
|
$this->stringContains($tableName),
|
||||||
|
$this->callback(function ($documents) {
|
||||||
|
return count($documents) === 1
|
||||||
|
&& 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'] ===
|
||||||
|
'Used as abstract as no abstract is defined.'
|
||||||
|
;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
$indexer = $objectManager->get(IndexerFactory::class)->getIndexer($tableName);
|
||||||
|
$this->inject($indexer, 'connection', $connection);
|
||||||
|
$indexer->indexAllDocuments();
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,14 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
|
||||||
|
|
||||||
class TcaIndexerTest extends AbstractFunctionalTestCase
|
class TcaIndexerTest extends AbstractFunctionalTestCase
|
||||||
{
|
{
|
||||||
|
protected function getTypoScriptFilesForFrontendRootPage()
|
||||||
|
{
|
||||||
|
return array_merge(
|
||||||
|
parent::getTypoScriptFilesForFrontendRootPage(),
|
||||||
|
['EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RespectRootLineBlacklist.ts']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
|
@ -69,12 +77,4 @@ class TcaIndexerTest extends AbstractFunctionalTestCase
|
||||||
|
|
||||||
$objectManager->get(TcaIndexer::class, $tableService, $connection)->indexAllDocuments();
|
$objectManager->get(TcaIndexer::class, $tableService, $connection)->indexAllDocuments();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTypoScriptFilesForFrontendRootPage()
|
|
||||||
{
|
|
||||||
return array_merge(
|
|
||||||
parent::getTypoScriptFilesForFrontendRootPage(),
|
|
||||||
['EXT:search_core/Tests/Functional/Fixtures/Indexing/TcaIndexer/RespectRootLineBlacklist.ts']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue