LoggerDataCollectorTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\HttpKernel\DataCollector;
  11. use Symfony\Component\HttpKernel\DataCollector\LoggerDataCollector;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
  15. use Symfony\Tests\Component\HttpKernel\Logger;
  16. class LoggerDataCollectorTest extends \PHPUnit_Framework_TestCase
  17. {
  18. public function testCollect()
  19. {
  20. $c = new LoggerDataCollector(new TestLogger());
  21. $c->collect(new Request(), new Response());
  22. $this->assertSame('logger',$c->getName());
  23. $this->assertSame(1337,$c->countErrors());
  24. $this->assertSame(array('foo'),$c->getLogs());
  25. }
  26. }
  27. class TestLogger extends Logger implements DebugLoggerInterface
  28. {
  29. public function countErrors()
  30. {
  31. return 1337;
  32. }
  33. public function getDebugLogger()
  34. {
  35. return new static();
  36. }
  37. public function getLogs($priority = false)
  38. {
  39. return array('foo');
  40. }
  41. }