Skip to content
Snippets Groups Projects
Commit 85b06984 authored by Morton Jonuschat's avatar Morton Jonuschat Committed by Christian Kuhn
Browse files

[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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarMona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: default avatarMona Muzaffar <mona.muzaffar@gmx.de>
parent 0ff6f6df
Branches
Tags
No related merge requests found
......@@ -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\\_%'"
],
];
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment