Skip to content

Commit

Permalink
Merge pull request #50 from NicoMaia/master
Browse files Browse the repository at this point in the history
Add support to Doctrine Echo Logger
  • Loading branch information
patrickbrouwers committed Sep 24, 2015
2 parents 36561d1 + d1f6f63 commit 55a0c4a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Loggers/EchoLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace LaravelDoctrine\ORM\Loggers;

use Doctrine\DBAL\Logging\EchoSQLLogger;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;

class EchoLogger implements Logger
{
/**
* @param EntityManagerInterface $em
* @param Configuration $configuration
*/
public function register(EntityManagerInterface $em, Configuration $configuration)
{
$configuration->setSQLLogger(new EchoSQLLogger());
}
}
22 changes: 22 additions & 0 deletions tests/Loggers/EchoLoggerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use LaravelDoctrine\ORM\Loggers\EchoLogger;
use Mockery as m;

class EchoLoggerTest extends PHPUnit_Framework_TestCase
{
public function test_can_register()
{
$em = m::mock(EntityManagerInterface::class);
$configuration = m::mock(Configuration::class);

$configuration->shouldReceive('setSQLLogger')
->once();

$logger = new EchoLogger();

$logger->register($em, $configuration);
}
}

0 comments on commit 55a0c4a

Please sign in to comment.