2010-02-01 21:56:06 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\DBAL\Events;
|
|
|
|
|
|
|
|
use Doctrine\Tests\DbalTestCase;
|
|
|
|
use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
|
|
|
|
use Doctrine\DBAL\Event\ConnectionEventArgs;
|
|
|
|
use Doctrine\DBAL\Events;
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../../TestInit.php';
|
|
|
|
|
|
|
|
class MysqlSessionInitTest extends DbalTestCase
|
|
|
|
{
|
|
|
|
public function testPostConnect()
|
|
|
|
{
|
|
|
|
$connectionMock = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
|
|
|
|
$connectionMock->expects($this->once())
|
|
|
|
->method('executeUpdate')
|
2010-02-01 22:20:37 +03:00
|
|
|
->with($this->equalTo("SET NAMES foo COLLATE bar"));
|
2010-02-01 21:56:06 +03:00
|
|
|
|
|
|
|
$eventArgs = new ConnectionEventArgs($connectionMock);
|
|
|
|
|
|
|
|
|
|
|
|
$listener = new MysqlSessionInit('foo', 'bar');
|
|
|
|
$listener->postConnect($eventArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetSubscribedEvents()
|
|
|
|
{
|
|
|
|
$listener = new MysqlSessionInit();
|
|
|
|
$this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
|
|
|
|
}
|
|
|
|
}
|