LoggingTest.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Doctrine\Tests\DBAL\Functional;
  3. require_once __DIR__ . '/../../TestInit.php';
  4. class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase
  5. {
  6. public function testLogExecuteQuery()
  7. {
  8. $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
  9. $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
  10. $logMock->expects($this->at(0))
  11. ->method('startQuery')
  12. ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
  13. $logMock->expects($this->at(1))
  14. ->method('stopQuery');
  15. $this->_conn->getConfiguration()->setSQLLogger($logMock);
  16. $this->_conn->executeQuery($sql, array());
  17. }
  18. public function testLogExecuteUpdate()
  19. {
  20. $this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).');
  21. $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
  22. $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
  23. $logMock->expects($this->at(0))
  24. ->method('startQuery')
  25. ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
  26. $logMock->expects($this->at(1))
  27. ->method('stopQuery');
  28. $this->_conn->getConfiguration()->setSQLLogger($logMock);
  29. $this->_conn->executeUpdate($sql, array());
  30. }
  31. public function testLogPrepareExecute()
  32. {
  33. $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();
  34. $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
  35. $logMock->expects($this->once())
  36. ->method('startQuery')
  37. ->with($this->equalTo($sql), $this->equalTo(array()));
  38. $logMock->expects($this->at(1))
  39. ->method('stopQuery');
  40. $this->_conn->getConfiguration()->setSQLLogger($logMock);
  41. $stmt = $this->_conn->prepare($sql);
  42. $stmt->execute();
  43. }
  44. }