diff --git a/src/Symfony/Bridge/Doctrine/CHANGELOG.md b/src/Symfony/Bridge/Doctrine/CHANGELOG.md index ada3e62928..6369ea3634 100644 --- a/src/Symfony/Bridge/Doctrine/CHANGELOG.md +++ b/src/Symfony/Bridge/Doctrine/CHANGELOG.md @@ -10,3 +10,5 @@ CHANGELOG * DoctrineType now caches its choice lists in order to improve performance * DoctrineType now uses ManagerRegistry::getManagerForClass() if the option "em" is not set * UniqueEntity validation constraint now accepts a "repositoryMethod" option that will be used to check for uniqueness instead of the default "findBy" + * [BC BREAK] the DbalLogger::log() visibility has been changed from public to + protected diff --git a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php index 066ff8a674..921dbdf880 100644 --- a/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php +++ b/src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php @@ -47,7 +47,7 @@ class DbalLogger implements SQLLogger } if (null !== $this->logger) { - $this->log($sql.' ('.json_encode($params).')'); + $this->log($sql, null === $params ? array() : $params); } } @@ -65,9 +65,10 @@ class DbalLogger implements SQLLogger * Logs a message. * * @param string $message A message to log + * @param array $params The context */ - public function log($message) + protected function log($message, array $params) { - $this->logger->debug($message); + $this->logger->debug($message, $params); } } diff --git a/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php new file mode 100644 index 0000000000..ffb5c447a1 --- /dev/null +++ b/src/Symfony/Bridge/Doctrine/Tests/Logger/DbalLoggerTest.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\Doctrine\Tests\Logger; + + +class DbalLoggerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getLogFixtures + */ + public function testLog($sql, $params, $logParams) + { + $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface'); + + $dbalLogger = $this + ->getMockBuilder('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger') + ->setConstructorArgs(array($logger, null)) + ->setMethods(array('log')) + ->getMock() + ; + + $dbalLogger + ->expects($this->once()) + ->method('log') + ->with($sql, $logParams) + ; + + $dbalLogger->startQuery($sql, $params); + } + + public function getLogFixtures() + { + return array( + array('SQL', null, array()), + array('SQL', array(), array()), + array('SQL', array('foo' => 'bar'), array('foo' => 'bar')) + ); + } +}