Commit eff314db authored by Steve Müller's avatar Steve Müller

add functional driver test case for connecting without dbname parameter

parent 0f36c991
<?php
namespace Doctrine\Tests\DBAL\Functional\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\Tests\DbalFunctionalTestCase;
abstract class AbstractDriverTest extends DbalFunctionalTestCase
{
/**
* The driver instance under test.
*
* @var \Doctrine\DBAL\Driver
*/
private $driver;
protected function setUp()
{
parent::setUp();
$this->driver = $this->createDriver();
}
/**
* @group DBAL-1215
*/
public function testConnectsWithoutDatabaseNameParameter()
{
$params = $this->_conn->getParams();
unset($params['dbname']);
$user = isset($params['user']) ? $params['user'] : null;
$password = isset($params['password']) ? $params['password'] : null;
$connection = $this->driver->connect($params, $user, $password);
$this->assertInstanceOf('Doctrine\DBAL\Driver\Connection', $connection);
}
/**
* @group DBAL-1215
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
{
$params = $this->_conn->getParams();
unset($params['dbname']);
$connection = new Connection(
$params,
$this->_conn->getDriver(),
$this->_conn->getConfiguration(),
$this->_conn->getEventManager()
);
$this->assertSame(
$this->getDatabaseNameForConnectionWithoutDatabaseNameParameter(),
$this->driver->getDatabase($connection)
);
}
/**
* @return \Doctrine\DBAL\Driver
*/
abstract protected function createDriver();
/**
* @return string|null
*/
protected function getDatabaseNameForConnectionWithoutDatabaseNameParameter()
{
return null;
}
}
<?php
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOPgSql;
use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
class DriverTest extends AbstractDriverTest
{
protected function setUp()
{
if (! extension_loaded('pdo_pgsql')) {
$this->markTestSkipped('pdo_pgsql is not installed.');
}
parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('pdo_pgsql only test.');
}
}
/**
* {@inheritdoc}
*/
protected function createDriver()
{
return new Driver();
}
/**
* {@inheritdoc}
*/
protected function getDatabaseNameForConnectionWithoutDatabaseNameParameter()
{
return 'template1';
}
}
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