Completed
Pull Request — master (#3809)
by Sergei
63:55
created

OCI8StatementTest::testExecute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 34
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 34
rs 9.568
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\DBAL\Driver\OCI8;
6
7
use Doctrine\DBAL\Driver\OCI8\OCI8Exception;
8
use Doctrine\DBAL\Driver\OCI8\OCI8Statement;
9
use Doctrine\Tests\DbalTestCase;
10
use function extension_loaded;
11
12
class OCI8StatementTest extends DbalTestCase
13
{
14
    protected function setUp() : void
15
    {
16
        if (! extension_loaded('oci8')) {
17
            $this->markTestSkipped('oci8 is not installed.');
18
        }
19
20
        parent::setUp();
21
    }
22
23
    /**
24
     * @dataProvider nonTerminatedLiteralProvider
25
     */
26
    public function testConvertNonTerminatedLiteral(string $sql, string $message) : void
27
    {
28
        $this->expectException(OCI8Exception::class);
29
        $this->expectExceptionMessageRegExp($message);
1 ignored issue
show
Deprecated Code introduced by
The function PHPUnit\Framework\TestCa...xceptionMessageRegExp() has been deprecated: Use expectExceptionMessageMatches() instead ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

29
        /** @scrutinizer ignore-deprecated */ $this->expectExceptionMessageRegExp($message);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
30
        OCI8Statement::convertPositionalToNamedPlaceholders($sql);
31
    }
32
33
    /**
34
     * @return array<string, array<int, mixed>>
35
     */
36
    public static function nonTerminatedLiteralProvider() : iterable
37
    {
38
        return [
39
            'no-matching-quote' => [
40
                "SELECT 'literal FROM DUAL",
41
                '/offset 7./',
42
            ],
43
            'no-matching-double-quote' => [
44
                'SELECT 1 "COL1 FROM DUAL',
45
                '/offset 9./',
46
            ],
47
            'incorrect-escaping-syntax' => [
48
                "SELECT 'quoted \\'string' FROM DUAL",
49
                '/offset 23./',
50
            ],
51
        ];
52
    }
53
}
54