LoggingTest.php 1.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
<?php

namespace Doctrine\Tests\DBAL\Functional;

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

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

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

25 26
        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();

27
        $logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger');
28 29 30 31 32 33 34 35 36
        $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());
    }

37 38 39 40
    public function testLogPrepareExecute()
    {
        $sql = $this->_conn->getDatabasePlatform()->getDummySelectSQL();

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

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