4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests\EventListener;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Console\ConsoleEvents;
16 use Symfony\Component\HttpKernel\EventListener\DumpListener;
17 use Symfony\Component\VarDumper\Cloner\ClonerInterface;
18 use Symfony\Component\VarDumper\Cloner\Data;
19 use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
20 use Symfony\Component\VarDumper\VarDumper;
25 * @author Nicolas Grekas <p@tchwork.com>
27 class DumpListenerTest extends TestCase
29 public function testSubscribedEvents()
32 array(ConsoleEvents::COMMAND => array('configure', 1024)),
33 DumpListener::getSubscribedEvents()
37 public function testConfigure()
39 $prevDumper = VarDumper::setHandler('var_dump');
40 VarDumper::setHandler($prevDumper);
42 $cloner = new MockCloner();
43 $dumper = new MockDumper();
47 $listener = new DumpListener($cloner, $dumper);
50 $listener->configure();
52 VarDumper::dump('foo');
53 VarDumper::dump('bar');
55 $this->assertSame('+foo-+bar-', ob_get_clean());
56 } catch (\Exception $exception) {
59 VarDumper::setHandler($prevDumper);
61 if (null !== $exception) {
67 class MockCloner implements ClonerInterface
69 public function cloneVar($var)
71 return new Data(array($var.'-'));
75 class MockDumper implements DataDumperInterface
77 public function dump(Data $data)
79 $rawData = $data->getRawData();