LoggingTest.php 1.9 KB

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