MysqlSessionInitTest.php 983B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Doctrine\Tests\DBAL\Events;
  3. use Doctrine\Tests\DbalTestCase;
  4. use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
  5. use Doctrine\DBAL\Event\ConnectionEventArgs;
  6. use Doctrine\DBAL\Events;
  7. require_once __DIR__ . '/../../TestInit.php';
  8. class MysqlSessionInitTest extends DbalTestCase
  9. {
  10. public function testPostConnect()
  11. {
  12. $connectionMock = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
  13. $connectionMock->expects($this->once())
  14. ->method('executeUpdate')
  15. ->with($this->equalTo("SET NAMES foo COLLATE bar"));
  16. $eventArgs = new ConnectionEventArgs($connectionMock);
  17. $listener = new MysqlSessionInit('foo', 'bar');
  18. $listener->postConnect($eventArgs);
  19. }
  20. public function testGetSubscribedEvents()
  21. {
  22. $listener = new MysqlSessionInit();
  23. $this->assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
  24. }
  25. }