LoggingTest.php 1.94 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php

namespace Doctrine\Tests\DBAL\Functional;

require_once __DIR__ . '/../../TestInit.php';

class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
    public function testLogExecuteQuery()
    {
        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();

        $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
14 15 16 17 18
        $logMock->expects($this->at(0))
                ->method('startQuery')
                ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
        $logMock->expects($this->at(1))
                ->method('stopQuery');
19 20 21 22
        $this->_conn->getConfiguration()->setSQLLogger($logMock);
        $this->_conn->executeQuery($sql, array());
    }

23 24
    public function testLogExecuteUpdate()
    {
25 26
        $this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).');

27 28 29 30 31 32 33 34 35 36 37 38
        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();

        $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
        $logMock->expects($this->at(0))
                ->method('startQuery')
                ->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array()));
        $logMock->expects($this->at(1))
                ->method('stopQuery');
        $this->_conn->getConfiguration()->setSQLLogger($logMock);
        $this->_conn->executeUpdate($sql, array());
    }

39 40 41 42 43 44
    public function testLogPrepareExecute()
    {
        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();

        $logMock = $this->getMock('Doctrine\DBAL\Logging\SQLLogger');
        $logMock->expects($this->once())
45 46 47 48
                ->method('startQuery')
                ->with($this->equalTo($sql), $this->equalTo(array()));
        $logMock->expects($this->at(1))
                ->method('stopQuery');
49 50 51 52 53 54
        $this->_conn->getConfiguration()->setSQLLogger($logMock);

        $stmt = $this->_conn->prepare($sql);
        $stmt->execute();
    }
}