StatementTest.php 1.11 KB
Newer Older
1 2 3 4 5
<?php

namespace Doctrine\Tests\DBAL\Functional\Driver\SQLSrv;

use Doctrine\DBAL\Driver\SQLSrv\Driver;
6
use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException;
7
use Doctrine\Tests\DbalFunctionalTestCase;
8
use function extension_loaded;
9 10 11

class StatementTest extends DbalFunctionalTestCase
{
12
    protected function setUp() : void
13
    {
Sergei Morozov's avatar
Sergei Morozov committed
14
        if (! extension_loaded('sqlsrv')) {
15
            self::markTestSkipped('sqlsrv is not installed.');
16 17 18 19
        }

        parent::setUp();

Sergei Morozov's avatar
Sergei Morozov committed
20
        if ($this->connection->getDriver() instanceof Driver) {
Sergei Morozov's avatar
Sergei Morozov committed
21
            return;
22
        }
Sergei Morozov's avatar
Sergei Morozov committed
23 24

        self::markTestSkipped('sqlsrv only test');
25 26
    }

27
    public function testFailureToPrepareResultsInException() : void
28 29
    {
        // use the driver connection directly to avoid having exception wrapped
Sergei Morozov's avatar
Sergei Morozov committed
30
        $stmt = $this->connection->getWrappedConnection()->prepare(null);
31 32 33

        // it's impossible to prepare the statement without bound variables for SQL Server,
        // so the preparation happens before the first execution when variables are already in place
34
        $this->expectException(SQLSrvException::class);
35 36 37
        $stmt->execute();
    }
}