Failed Conditions
Pull Request — develop (#3523)
by
unknown
65:32
created

DriverTest::testDriverOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv;
6
7
use Doctrine\DBAL\Driver\Connection;
8
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
9
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
10
use function extension_loaded;
11
12
class DriverTest extends AbstractDriverTest
13
{
14
    protected function setUp() : void
15
    {
16
        if (! extension_loaded('pdo_sqlsrv')) {
17
            $this->markTestSkipped('pdo_sqlsrv is not installed.');
18
        }
19
20
        parent::setUp();
21
22
        if ($this->connection->getDriver() instanceof Driver) {
23
            return;
24
        }
25
26
        $this->markTestSkipped('pdo_sqlsrv only test.');
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    protected function createDriver()
33
    {
34
        return new Driver();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string
41
    {
42
        return 'master';
43
    }
44
45
    /**
46
     * @param int[]|string[] $driverOptions
47
     */
48
    protected function getConnection(array $driverOptions) : Connection
49
    {
50
        return $this->connection->getDriver()->connect(
51
            [
52
                'host' => $GLOBALS['db_host'],
53
                'port' => $GLOBALS['db_port'],
54
            ],
55
            $GLOBALS['db_username'],
56
            $GLOBALS['db_password'],
57
            $driverOptions
58
        );
59
    }
60
61
    public function testConnectionOptions() : void
62
    {
63
        $connection = $this->getConnection(['APP' => 'APP_NAME']);
64
        $result     = $connection->query('SELECT APP_NAME()')->fetchColumn();
65
66
        self::assertSame('APP_NAME', $result);
67
    }
68
}
69