QuotingTest.php 751 Bytes
Newer Older
1 2
<?php

3
namespace Doctrine\DBAL\Tests\Functional\Platform;
4

5
use Doctrine\DBAL\Tests\FunctionalTestCase;
6

7
class QuotingTest extends FunctionalTestCase
8 9 10 11
{
    /**
     * @dataProvider stringLiteralProvider
     */
12
    public function testQuoteStringLiteral(string $string): void
13 14 15 16 17 18
    {
        $platform = $this->connection->getDatabasePlatform();
        $query    = $platform->getDummySelectSQL(
            $platform->quoteStringLiteral($string)
        );

19
        self::assertSame($string, $this->connection->fetchOne($query));
20 21 22 23 24
    }

    /**
     * @return mixed[][]
     */
25
    public static function stringLiteralProvider(): iterable
26 27 28 29 30 31 32
    {
        return [
            'backslash' => ['\\'],
            'single-quote' => ["'"],
        ];
    }
}