mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 09:16:21 +01:00
BUGFIX: Allow tests to run without database connection
Ad TYPO3 Core now makes use of Doctrine, a connection is required to build system where. Therefore we move it to an own method to exchange the execution inside of tests.
This commit is contained in:
parent
705e3be85a
commit
fc3c12fa96
2 changed files with 23 additions and 9 deletions
|
@ -142,15 +142,7 @@ class TcaTableService
|
|||
*/
|
||||
public function getWhereClause()
|
||||
{
|
||||
$whereClause = '1=1'
|
||||
. BackendUtility::BEenableFields($this->tableName)
|
||||
. BackendUtility::deleteClause($this->tableName)
|
||||
|
||||
. BackendUtility::BEenableFields('pages')
|
||||
. BackendUtility::deleteClause('pages')
|
||||
. ' AND pages.no_search = 0'
|
||||
;
|
||||
|
||||
$whereClause = $this->getSystemWhereClause();
|
||||
$userDefinedWhere = $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.additionalWhereClause');
|
||||
if (is_string($userDefinedWhere)) {
|
||||
$whereClause .= ' AND ' . $userDefinedWhere;
|
||||
|
@ -169,6 +161,22 @@ class TcaTableService
|
|||
return $whereClause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate SQL for TYPO3 as a system, to make sure only available records
|
||||
* are fetched.
|
||||
*/
|
||||
public function getSystemWhereClause() : string
|
||||
{
|
||||
return '1=1'
|
||||
. BackendUtility::BEenableFields($this->tableName)
|
||||
. BackendUtility::deleteClause($this->tableName)
|
||||
|
||||
. BackendUtility::BEenableFields('pages')
|
||||
. BackendUtility::deleteClause('pages')
|
||||
. ' AND pages.no_search = 0'
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -60,6 +60,9 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
|||
->method('getIfExists')
|
||||
->withConsecutive(['indexing.table.additionalWhereClause'], ['indexing.table.rootLineBlacklist'])
|
||||
->will($this->onConsecutiveCalls(null, false));
|
||||
$this->subject->expects($this->once())
|
||||
->method('getSystemWhereClause')
|
||||
->will($this->returnValue('1=1 AND pages.no_search = 0'));
|
||||
|
||||
$this->assertSame(
|
||||
'1=1 AND pages.no_search = 0',
|
||||
|
@ -76,6 +79,9 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
|||
->method('getIfExists')
|
||||
->withConsecutive(['indexing.table.additionalWhereClause'], ['indexing.table.rootLineBlacklist'])
|
||||
->will($this->onConsecutiveCalls('table.field = "someValue"', false));
|
||||
$this->subject->expects($this->once())
|
||||
->method('getSystemWhereClause')
|
||||
->will($this->returnValue('1=1 AND pages.no_search = 0'));
|
||||
|
||||
$this->assertSame(
|
||||
'1=1 AND pages.no_search = 0 AND table.field = "someValue"',
|
||||
|
|
Loading…
Reference in a new issue