EventDataCollectorTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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\EventDataCollector;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\HttpKernel\Debug\EventDispatcherTraceableInterface;
  15. use Symfony\Component\EventDispatcher\EventDispatcher;
  16. class EventDataCollectorTest extends \PHPUnit_Framework_TestCase
  17. {
  18. public function testCollect()
  19. {
  20. $c = new EventDataCollector();
  21. $c->setEventDispatcher(new TestEventDispatcher());
  22. $c->collect(new Request(), new Response());
  23. $this->assertSame('events',$c->getName());
  24. $this->assertSame(array('foo'),$c->getCalledListeners());
  25. $this->assertSame(array('bar'),$c->getNotCalledListeners());
  26. }
  27. }
  28. class TestEventDispatcher extends EventDispatcher implements EventDispatcherTraceableInterface
  29. {
  30. function getCalledListeners()
  31. {
  32. return array('foo');
  33. }
  34. function getNotCalledListeners()
  35. {
  36. return array('bar');
  37. }
  38. }