SQLSessionInitTest.php 1.04 KB
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\SQLSessionInit;
7
use Doctrine\DBAL\Events;
jeroendedauw's avatar
jeroendedauw committed
8
use Doctrine\Tests\DbalTestCase;
9 10 11 12 13 14 15 16

/**
 * @group DBAL-169
 */
class SQLSessionInitTest extends DbalTestCase
{
    public function testPostConnect()
    {
17
        $connectionMock = $this->createMock('Doctrine\DBAL\Connection');
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
        $connectionMock->expects($this->once())
                       ->method('exec')
                       ->with($this->equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));

        $eventArgs = new ConnectionEventArgs($connectionMock);

        $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
        $listener->postConnect($eventArgs);
    }

    public function testGetSubscribedEvents()
    {
        $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
        $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
    }
33
}