Passed
Pull Request — master (#3013)
by Grégoire
14:35
created

LikeWildcardsEscapingTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

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