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

LikeWildcardsEscapingTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testFetchLikeExpressionResult() 0 12 1
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