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:
Daniel Siepmann 2017-07-07 12:19:35 +02:00
parent 705e3be85a
commit fc3c12fa96
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 23 additions and 9 deletions

View file

@ -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
*/

View file

@ -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"',