Commit f471a0fd authored by Kim Hemsø Rasmussen's avatar Kim Hemsø Rasmussen

Added tests for all variants

parent d7bbd303
...@@ -5,6 +5,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOPgSql; ...@@ -5,6 +5,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOPgSql;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\PDOPgSql\Driver; use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use Doctrine\Tests\TestUtil;
class DriverTest extends AbstractDriverTest class DriverTest extends AbstractDriverTest
{ {
...@@ -21,12 +22,14 @@ class DriverTest extends AbstractDriverTest ...@@ -21,12 +22,14 @@ class DriverTest extends AbstractDriverTest
} }
} }
public function testDefaultDatabaseOption() /**
@dataProvider getDatabaseParameter
*/
public function testDatabaseParameters($databaseName, $defaultDatabaseName, $expectedDatabaseName)
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$dbName = $params['dbname']; $params['dbname'] = $databaseName;
$params['default_dbname'] = $dbName; $params['default_dbname'] = $defaultDatabaseName;
unset($params['dbname']);
$connection = new Connection( $connection = new Connection(
$params, $params,
...@@ -36,11 +39,26 @@ class DriverTest extends AbstractDriverTest ...@@ -36,11 +39,26 @@ class DriverTest extends AbstractDriverTest
); );
$this->assertSame( $this->assertSame(
$dbName, $expectedDatabaseName,
$this->driver->getDatabase($connection) $this->driver->getDatabase($connection)
); );
} }
public function getDatabaseParameter()
{
$params = TestUtil::getConnection()->getParams();
$realDatabaseName = $params['dbname'];
$dummyDatabaseName = $realDatabaseName . 'a';
return array(
// dbname, default_dbname, expected
array($realDatabaseName, null, $realDatabaseName),
array($realDatabaseName, $dummyDatabaseName, $realDatabaseName),
array(null, $realDatabaseName, $realDatabaseName),
array(null, null, $this->getDatabaseNameForConnectionWithoutDatabaseNameParameter()),
);
}
/** /**
* @group DBAL-1146 * @group DBAL-1146
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment