Blame view
sources/3rdparty/doctrine/dbal/tests/Doctrine/Tests/DBAL/DriverManagerTest.php
3.19 KB
|
31b7f2792
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
<?php
namespace Doctrine\Tests\DBAL;
require_once __DIR__ . '/../TestInit.php';
class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
{
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public function testInvalidPdoInstance()
{
$options = array(
'pdo' => 'test'
);
$test = \Doctrine\DBAL\DriverManager::getConnection($options);
}
public function testValidPdoInstance()
{
$options = array(
'pdo' => new \PDO('sqlite::memory:')
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
$this->assertEquals('sqlite', $conn->getDatabasePlatform()->getName());
}
/**
* @group DBAL-32
*/
public function testPdoInstanceSetErrorMode()
{
$pdo = new \PDO('sqlite::memory:');
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT);
$options = array(
'pdo' => $pdo
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
$this->assertEquals(\PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(\PDO::ATTR_ERRMODE));
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public function testCheckParams()
{
$conn = \Doctrine\DBAL\DriverManager::getConnection(array());
}
/**
* @expectedException \Doctrine\DBAL\DBALException
*/
public function testInvalidDriver()
{
$conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'invalid_driver'));
}
public function testCustomPlatform()
{
$mockPlatform = new \Doctrine\Tests\DBAL\Mocks\MockPlatform();
$options = array(
'pdo' => new \PDO('sqlite::memory:'),
'platform' => $mockPlatform
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
$this->assertSame($mockPlatform, $conn->getDatabasePlatform());
}
public function testCustomWrapper()
{
$wrapperClass = 'Doctrine\Tests\Mocks\ConnectionMock';
$options = array(
'pdo' => new \PDO('sqlite::memory:'),
'wrapperClass' => $wrapperClass,
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
$this->assertInstanceOf($wrapperClass, $conn);
}
public function testInvalidWrapperClass()
{
$this->setExpectedException('\Doctrine\DBAL\DBALException');
$options = array(
'pdo' => new \PDO('sqlite::memory:'),
'wrapperClass' => 'stdClass',
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
}
public function testInvalidDriverClass()
{
$this->setExpectedException('\Doctrine\DBAL\DBALException');
$options = array(
'driverClass' => 'stdClass'
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
}
public function testValidDriverClass()
{
$options = array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
);
$conn = \Doctrine\DBAL\DriverManager::getConnection($options);
$this->assertInstanceOf('Doctrine\DBAL\Driver\PDOMySql\Driver', $conn->getDriver());
}
}
|