mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 14:36:11 +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()
|
public function getWhereClause()
|
||||||
{
|
{
|
||||||
$whereClause = '1=1'
|
$whereClause = $this->getSystemWhereClause();
|
||||||
. BackendUtility::BEenableFields($this->tableName)
|
|
||||||
. BackendUtility::deleteClause($this->tableName)
|
|
||||||
|
|
||||||
. BackendUtility::BEenableFields('pages')
|
|
||||||
. BackendUtility::deleteClause('pages')
|
|
||||||
. ' AND pages.no_search = 0'
|
|
||||||
;
|
|
||||||
|
|
||||||
$userDefinedWhere = $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.additionalWhereClause');
|
$userDefinedWhere = $this->configuration->getIfExists('indexing.' . $this->getTableName() . '.additionalWhereClause');
|
||||||
if (is_string($userDefinedWhere)) {
|
if (is_string($userDefinedWhere)) {
|
||||||
$whereClause .= ' AND ' . $userDefinedWhere;
|
$whereClause .= ' AND ' . $userDefinedWhere;
|
||||||
|
@ -169,6 +161,22 @@ class TcaTableService
|
||||||
return $whereClause;
|
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
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -60,6 +60,9 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
||||||
->method('getIfExists')
|
->method('getIfExists')
|
||||||
->withConsecutive(['indexing.table.additionalWhereClause'], ['indexing.table.rootLineBlacklist'])
|
->withConsecutive(['indexing.table.additionalWhereClause'], ['indexing.table.rootLineBlacklist'])
|
||||||
->will($this->onConsecutiveCalls(null, false));
|
->will($this->onConsecutiveCalls(null, false));
|
||||||
|
$this->subject->expects($this->once())
|
||||||
|
->method('getSystemWhereClause')
|
||||||
|
->will($this->returnValue('1=1 AND pages.no_search = 0'));
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
'1=1 AND pages.no_search = 0',
|
'1=1 AND pages.no_search = 0',
|
||||||
|
@ -76,6 +79,9 @@ class TcaTableServiceTest extends AbstractUnitTestCase
|
||||||
->method('getIfExists')
|
->method('getIfExists')
|
||||||
->withConsecutive(['indexing.table.additionalWhereClause'], ['indexing.table.rootLineBlacklist'])
|
->withConsecutive(['indexing.table.additionalWhereClause'], ['indexing.table.rootLineBlacklist'])
|
||||||
->will($this->onConsecutiveCalls('table.field = "someValue"', false));
|
->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(
|
$this->assertSame(
|
||||||
'1=1 AND pages.no_search = 0 AND table.field = "someValue"',
|
'1=1 AND pages.no_search = 0 AND table.field = "someValue"',
|
||||||
|
|
Loading…
Reference in a new issue