From 171e2fdc337d3730bbcff46a017b2fe99a4821d0 Mon Sep 17 00:00:00 2001 From: Morton Jonuschat <m.jonuschat@mojocode.de> Date: Sun, 19 Feb 2017 21:09:01 -0800 Subject: [PATCH] [BUGFIX] Fix functional tests for EXT:frontend on PostgreSQL Replace the MySQL specific backtick quoting with the actual quote character in test checking for SQL fragments/quoting of fields. Change assertions that assume integer return values from the database driver to also accept string types using assertEquals(). Resolves: #79797 Releases: master Change-Id: I1f78b0b65cdcceeaefa23902d14fa0988198d849 Reviewed-on: https://review.typo3.org/51764 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Manuel Selbach <manuel_selbach@yahoo.de> Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de> Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../ContentObject/ContentObjectRendererTest.php | 17 +++++++++++++++++ .../Functional/Page/PageRepositoryTest.php | 16 ++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php index f8d4d4d348bc..cd13ccc07f06 100644 --- a/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\ContentObject; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\TypoScript\TemplateService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; @@ -30,6 +31,11 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ */ protected $subject; + /** + * @var string + */ + protected $quoteChar; + protected function setUp() { parent::setUp(); @@ -45,6 +51,10 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ $GLOBALS['TSFE'] = $typoScriptFrontendController; $this->subject = GeneralUtility::makeInstance(ContentObjectRenderer::class); + $this->quoteChar = GeneralUtility::makeInstance(ConnectionPool::class) + ->getConnectionForTable('tt_content') + ->getDatabasePlatform() + ->getIdentifierQuoteCharacter(); } /** @@ -181,6 +191,10 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ $result = $this->subject->getQuery($table, $conf, true); foreach ($expected as $field => $value) { + // Replace the MySQL backtick quote character with the actual quote character for the DBMS + if ($field === 'SELECT') { + $value = str_replace('`', $this->quoteChar, $value); + } $this->assertEquals($value, $result[$field]); } } @@ -329,6 +343,9 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ ->method('checkPidArray') ->willReturn(explode(',', $configuration['pidInList'])); + // Replace the MySQL backtick quote character with the actual quote character for the DBMS + $expectedResult = str_replace('`', $this->quoteChar, $expectedResult); + // Embed the enable fields string into the expected result as the database // connection is still unconfigured when the data provider is being run. $expectedResult = sprintf($expectedResult, $GLOBALS['TSFE']->sys_page->enableFields($table)); diff --git a/typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php b/typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php index b368052fab0e..af41fda9f0a3 100644 --- a/typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php @@ -386,10 +386,10 @@ class PageRepositoryTest extends \TYPO3\TestingFramework\Core\Functional\Functio $pageRec = $this->pageRepo->getPage(11); - $this->assertSame(11, $pageRec['uid']); - $this->assertSame(11, $pageRec['t3ver_oid']); - $this->assertSame(987654321, $pageRec['t3ver_wsid']); - $this->assertSame(-1, $pageRec['t3ver_state']); + $this->assertEquals(11, $pageRec['uid']); + $this->assertEquals(11, $pageRec['t3ver_oid']); + $this->assertEquals(987654321, $pageRec['t3ver_wsid']); + $this->assertEquals(-1, $pageRec['t3ver_state']); $this->assertSame('First draft version', $pageRec['t3ver_label']); } @@ -408,10 +408,10 @@ class PageRepositoryTest extends \TYPO3\TestingFramework\Core\Functional\Functio $pageRec = $this->pageRepo->getWorkspaceVersionOfRecord($wsid, 'pages', 11); - $this->assertSame(12, $pageRec['uid']); - $this->assertSame(11, $pageRec['t3ver_oid']); - $this->assertSame(987654321, $pageRec['t3ver_wsid']); - $this->assertSame(-1, $pageRec['t3ver_state']); + $this->assertEquals(12, $pageRec['uid']); + $this->assertEquals(11, $pageRec['t3ver_oid']); + $this->assertEquals(987654321, $pageRec['t3ver_wsid']); + $this->assertEquals(-1, $pageRec['t3ver_state']); $this->assertSame('First draft version', $pageRec['t3ver_label']); } -- GitLab