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

testFetchLikeExpressionResult()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 11
nc 1
nop 0
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