1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\DBAL\Driver\PDOSqlsrv;
|
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
|
6
|
|
|
use Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest;
|
7
|
|
|
use PDO;
|
8
|
|
|
|
9
|
|
|
class DriverTest extends AbstractSQLServerDriverTest
|
10
|
|
|
{
|
11
|
|
|
public function testReturnsName()
|
12
|
|
|
{
|
13
|
|
|
self::assertSame('pdo_sqlsrv', $this->driver->getName());
|
14
|
|
|
}
|
15
|
|
|
|
16
|
|
|
protected function createDriver()
|
17
|
|
|
{
|
18
|
|
|
return new Driver();
|
19
|
|
|
}
|
20
|
|
|
|
21
|
|
|
public function testConnectionOptions()
|
22
|
|
|
{
|
23
|
|
|
$connection = $this->getConnection([
|
24
|
|
|
'APP' => 'APP_NAME',
|
25
|
|
|
'WSID' => 'WSID_NAME',
|
26
|
|
|
]);
|
27
|
|
|
|
28
|
|
|
$result = $connection->query("select APP_NAME() as app, HOST_NAME() as host")->fetch();
|
29
|
|
|
|
30
|
|
|
self::assertSame('APP_NAME', $result['app']);
|
31
|
|
|
self::assertSame('WSID_NAME', $result['host']);
|
32
|
|
|
}
|
33
|
|
|
|
34
|
|
|
public function testDriverOptions()
|
35
|
|
|
{
|
36
|
|
|
$connection = $this->getConnection([
|
37
|
|
|
PDO::ATTR_CASE => PDO::CASE_UPPER,
|
38
|
|
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
39
|
|
|
]);
|
40
|
|
|
|
41
|
|
|
self::assertSame(PDO::CASE_UPPER, $connection->getAttribute(PDO::ATTR_CASE));
|
42
|
|
|
self::assertSame(PDO::FETCH_ASSOC, $connection->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE));
|
43
|
|
|
}
|
44
|
|
|
|
45
|
|
|
private function getConnection($driverOptions) {
|
46
|
|
|
return $this->createDriver()->connect(
|
47
|
|
|
array(
|
48
|
|
|
'host' => $GLOBALS['db_host'],
|
49
|
|
|
'port' => $GLOBALS['db_port']
|
50
|
|
|
),
|
51
|
|
|
$GLOBALS['db_username'],
|
52
|
|
|
$GLOBALS['db_password'],
|
53
|
|
|
$driverOptions
|
54
|
|
|
);
|
55
|
|
|
}
|
56
|
|
|
|
57
|
|
|
/**
|
58
|
|
|
* @throws \PHPUnit_Framework_SkippedTestError
|
59
|
|
|
*/
|
60
|
|
|
private function skipWhenNotUsingPdoSqlsrv()
|
|
|
|
|
61
|
|
|
{
|
62
|
|
|
if (! (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_sqlsrv')) {
|
63
|
|
|
$this->markTestSkipped('Test enabled only when using pdo_sqlsrv specific phpunit.xml');
|
64
|
|
|
}
|
65
|
|
|
}
|
66
|
|
|
}
|
67
|
|
|
|
This check looks for private methods that have been defined, but are not used inside the class.