SQLSessionInitTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Doctrine\Tests\DBAL\Events;
  3. use Doctrine\Tests\DbalTestCase;
  4. use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
  5. use Doctrine\DBAL\Event\ConnectionEventArgs;
  6. use Doctrine\DBAL\Events;
  7. require_once __DIR__ . '/../../TestInit.php';
  8. /**
  9. * @group DBAL-169
  10. */
  11. class SQLSessionInitTest extends DbalTestCase
  12. {
  13. public function testPostConnect()
  14. {
  15. $connectionMock = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
  16. $connectionMock->expects($this->once())
  17. ->method('exec')
  18. ->with($this->equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));
  19. $eventArgs = new ConnectionEventArgs($connectionMock);
  20. $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
  21. $listener->postConnect($eventArgs);
  22. }
  23. public function testGetSubscribedEvents()
  24. {
  25. $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
  26. $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
  27. }
  28. }