MysqlSessionInitTest.php 936 Bytes
Newer Older
1 2 3 4 5
<?php

namespace Doctrine\Tests\DBAL\Events;

use Doctrine\DBAL\Event\ConnectionEventArgs;
jeroendedauw's avatar
jeroendedauw committed
6
use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
7
use Doctrine\DBAL\Events;
jeroendedauw's avatar
jeroendedauw committed
8
use Doctrine\Tests\DbalTestCase;
9 10 11 12 13 14 15 16

class MysqlSessionInitTest extends DbalTestCase
{
    public function testPostConnect()
    {
        $connectionMock = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
        $connectionMock->expects($this->once())
                       ->method('executeUpdate')
17
                       ->with($this->equalTo("SET NAMES foo COLLATE bar"));
18 19 20 21 22 23 24 25 26 27 28 29 30 31

        $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());
    }
}