From 85b0698445f98f071c22b45053a9801f6c9da483 Mon Sep 17 00:00:00 2001 From: Morton Jonuschat <m.jonuschat@mojocode.de> Date: Sun, 19 Feb 2017 21:21:30 -0800 Subject: [PATCH] [BUGFIX] Fix functional tests for EXT:indexed_search on PostgreSQL MySQL has support for backslash escape sequences. Change the tests to have the expected results without the additional escaping and add the additional slashes to the expected result if the database platform running the tests is MySQL. Change-Id: Ib2e30e95db507501aaea095eb3764a0d37135ec9 Resolves: #79799 Releases: master Reviewed-on: https://review.typo3.org/51765 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de> Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de> --- .../Tests/Functional/Utility/LikeWildcardTest.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/indexed_search/Tests/Functional/Utility/LikeWildcardTest.php b/typo3/sysext/indexed_search/Tests/Functional/Utility/LikeWildcardTest.php index ef9d5a02ae14..f6204e7861ec 100644 --- a/typo3/sysext/indexed_search/Tests/Functional/Utility/LikeWildcardTest.php +++ b/typo3/sysext/indexed_search/Tests/Functional/Utility/LikeWildcardTest.php @@ -13,6 +13,7 @@ namespace TYPO3\CMS\IndexedSearch\Tests\Unit\Utility; * * The TYPO3 project - inspiring people to share! */ +use Doctrine\DBAL\Platforms\MySqlPlatform; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\IndexedSearch\Utility\LikeWildcard; @@ -35,6 +36,11 @@ class LikeWildcardTest extends \TYPO3\TestingFramework\Core\Functional\Functiona { $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($tableName); $subject = LikeWildcard::cast($wildcard); + // MySQL has support for backslash escape sequences, the expected results needs to take + // the additional quoting into account. + if ($connection->getDatabasePlatform() instanceof MySqlPlatform) { + $expected = addcslashes($expected, '\\'); + } $expected = $connection->quoteIdentifier($fieldName) . ' ' . $expected; $this->assertSame($expected, $subject->getLikeQueryPart($tableName, $fieldName, $likeValue)); } @@ -86,21 +92,21 @@ class LikeWildcardTest extends \TYPO3\TestingFramework\Core\Functional\Functiona 'body', 'search_string', LikeWildcard::LEFT, - "LIKE '%search\\\\_string'" + "LIKE '%search\\_string'" ], 'percent placeholder and right wildcard mode' => [ 'tt_content', 'body', 'search%string', LikeWildcard::RIGHT, - "LIKE 'search\\\\%string%'" + "LIKE 'search\\%string%'" ], 'percent and underscore placeholder and both wildcards mode' => [ 'tt_content', 'body', '_search%string_', LikeWildcard::RIGHT, - "LIKE '\\\\_search\\\\%string\\\\_%'" + "LIKE '\\_search\\%string\\_%'" ], ]; } -- GitLab