MysqlSessionInitTest.php 910 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

class MysqlSessionInitTest extends DbalTestCase
{
    public function testPostConnect()
    {
14
        $connectionMock = $this->createMock('Doctrine\DBAL\Connection');
15 16
        $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

        $eventArgs = new ConnectionEventArgs($connectionMock);


        $listener = new MysqlSessionInit('foo', 'bar');
        $listener->postConnect($eventArgs);
    }

    public function testGetSubscribedEvents()
    {
        $listener = new MysqlSessionInit();
29
        self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
30
    }
31
}