[BUGFIX] Fix functional tests for EXT:frontend on PostgreSQL 64/51764/2
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Mon, 20 Feb 2017 05:09:01 +0000 (21:09 -0800)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 20 Feb 2017 13:55:16 +0000 (14:55 +0100)
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>
typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Functional/Page/PageRepositoryTest.php

index f8d4d4d..cd13ccc 100644 (file)
@@ -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));
index b368052..af41fda 100644 (file)
@@ -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']);
     }