Completed
Push — master ( 69742a...ea7657 )
by Marco
13s
created

LikeWildcardsEscapingTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFetchLikeExpressionResult() 0 17 1
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional;
4
5
use Doctrine\Tests\DbalFunctionalTestCase;
6
use function sprintf;
7
use function str_replace;
8
9
final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase
10
{
11
    public function testFetchLikeExpressionResult() : void
12
    {
13
        $string           = '_25% off_ your next purchase \o/ [$̲̅(̲̅5̲̅)̲̅$̲̅] (^̮^)';
14
        $escapeChar       = '!';
15
        $databasePlatform = $this->_conn->getDatabasePlatform();
16
        $stmt             = $this->_conn->prepare(str_replace(
17
            '1',
18
            sprintf(
19
                "(CASE WHEN '%s' LIKE '%s' ESCAPE '%s' THEN 1 ELSE 0 END)",
20
                $string,
21
                $databasePlatform->escapeStringForLike($string, $escapeChar),
22
                $escapeChar
23
            ),
24
            $databasePlatform->getDummySelectSQL()
25
        ));
26
        $stmt->execute();
27
        $this->assertTrue((bool) $stmt->fetchColumn());
28
    }
29
}
30