[DoctrineBridge] Fix log of non utf8 data

This commit is contained in:
Victor Berchet 2012-08-03 10:23:47 +02:00
parent 6f32078b1a
commit 6097c804ce
3 changed files with 54 additions and 3 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -0,0 +1,48 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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'))
);
}
}