3 namespace Doctrine\Tests\DBAL\Events;
5 use Doctrine\Tests\DbalTestCase;
6 use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
7 use Doctrine\DBAL\Event\ConnectionEventArgs;
8 use Doctrine\DBAL\Events;
10 require_once __DIR__ . '/../../TestInit.php';
15 class SQLSessionInitTest extends DbalTestCase
17 public function testPostConnect()
19 $connectionMock = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
20 $connectionMock->expects($this->once())
22 ->with($this->equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));
24 $eventArgs = new ConnectionEventArgs($connectionMock);
26 $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
27 $listener->postConnect($eventArgs);
30 public function testGetSubscribedEvents()
32 $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
33 $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());