1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/tests/Doctrine/Tests/DBAL/ConnectionTest.php

72 lines
2.0 KiB
PHP
Raw Normal View History

2009-07-15 02:36:09 +04:00
<?php
namespace Doctrine\Tests\DBAL;
require_once __DIR__ . '/../TestInit.php';
use Doctrine\DBAL\Connection;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Events;
2009-07-15 02:36:09 +04:00
class ConnectionTest extends \Doctrine\Tests\DbalTestCase
{
public function setUp()
{
$params = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => 'password',
'port' => '1234'
);
$this->_conn = \Doctrine\DBAL\DriverManager::getConnection($params);
}
public function testGetHost()
{
$this->assertEquals('localhost', $this->_conn->getHost());
}
public function testGetPort()
{
$this->assertEquals('1234', $this->_conn->getPort());
}
public function testGetUsername()
{
$this->assertEquals('root', $this->_conn->getUsername());
}
public function testGetPassword()
{
$this->assertEquals('password', $this->_conn->getPassword());
}
public function testGetDriver()
{
$this->assertType('Doctrine\DBAL\Driver\PDOMySql\Driver', $this->_conn->getDriver());
2009-07-15 02:36:09 +04:00
}
public function testGetEventManager()
{
$this->assertType('Doctrine\Common\EventManager', $this->_conn->getEventManager());
}
public function testConnectDispatchEvent()
{
$listenerMock = $this->getMock('ConnectDispatchEventListener', array('postConnect'));
$listenerMock->expects($this->once())->method('postConnect');
$eventManager = new EventManager();
$eventManager->addEventListener(array(Events::postConnect), $listenerMock);
$driverMock = $this->getMock('Doctrine\DBAL\Driver');
$driverMock->expects(($this->at(0)))
->method('connect');
$platform = new Mocks\MockPlatform();
$conn = new Connection(array('platform' => $platform), $driverMock, new Configuration(), $eventManager);
$conn->connect();
2009-07-15 02:36:09 +04:00
}
}