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

testFetchLikeExpressionResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional;
4
5
use Doctrine\Tests\DbalFunctionalTestCase;
6
7
final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase
8
{
9
    public function testFetchLikeExpressionResult() : void
10
    {
11
        $string = '_25% off_ your next purchase \o/';
12
        $escapeChar = '!';
13
        $stmt = $this->_conn->prepare(sprintf(
14
            "SELECT '%s' LIKE '%s' ESCAPE '%s' as it_matches",
15
            $string,
16
            $this->_conn->getDatabasePlatform()->escapeStringForLike($string, $escapeChar),
17
            $escapeChar
18
        ));
19
        $stmt->execute();
20
        $this->assertTrue((bool) $stmt->fetch()['it_matches']);
21
    }
22
}
23