Failed Conditions
Push — master ( 30b923...92920e )
by Marco
19s queued 13s
created

DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php (2 issues)

1
<?php
2
3
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv;
4
5
use Doctrine\DBAL\Driver\Connection;
6
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
7
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
8
use PDO;
9
use function extension_loaded;
10
11
class DriverTest extends AbstractDriverTest
12
{
13
    protected function setUp() : void
14
    {
15
        if (! extension_loaded('pdo_sqlsrv')) {
16
            $this->markTestSkipped('pdo_sqlsrv is not installed.');
17
        }
18
19
        parent::setUp();
20
21
        if ($this->connection->getDriver() instanceof Driver) {
22
            return;
23
        }
24
25
        $this->markTestSkipped('pdo_sqlsrv only test.');
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function createDriver()
32
    {
33
        return new Driver();
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function getDatabaseNameForConnectionWithoutDatabaseNameParameter()
40
    {
41
        return 'master';
42
    }
43
44
    /**
45
     * @param int[]|string[] $driverOptions
46
     */
47
    protected function getConnection(array $driverOptions) : Connection
48
    {
49
        return $this->connection->getDriver()->connect(
50
            [
51
                'host' => $GLOBALS['db_host'],
52
                'port' => $GLOBALS['db_port'],
53
            ],
54
            $GLOBALS['db_username'],
55
            $GLOBALS['db_password'],
56
            $driverOptions
57
        );
58
    }
59
60
    public function testConnectionOptions() : void
61
    {
62
        $connection = $this->getConnection(['APP' => 'APP_NAME']);
63
        $result     = $connection->query('SELECT APP_NAME()')->fetchColumn();
0 ignored issues
show
The call to Doctrine\DBAL\Driver\Connection::query() has too many arguments starting with 'SELECT APP_NAME()'. ( Ignorable by Annotation )

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

63
        $result     = $connection->/** @scrutinizer ignore-call */ query('SELECT APP_NAME()')->fetchColumn();

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
64
65
        self::assertSame('APP_NAME', $result);
66
    }
67
68
    public function testDriverOptions() : void
69
    {
70
        $connection = $this->getConnection([PDO::ATTR_CASE => PDO::CASE_UPPER]);
71
72
        self::assertSame(PDO::CASE_UPPER, $connection->getAttribute(PDO::ATTR_CASE));
0 ignored issues
show
The method getAttribute() does not exist on Doctrine\DBAL\Driver\Connection. It seems like you code against a sub-type of Doctrine\DBAL\Driver\Connection such as Doctrine\DBAL\Driver\PDOConnection. ( Ignorable by Annotation )

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

72
        self::assertSame(PDO::CASE_UPPER, $connection->/** @scrutinizer ignore-call */ getAttribute(PDO::ATTR_CASE));
Loading history...
73
    }
74
}
75