public function ContainerAwareTraceableEventDispatcherTest::testClosureDoesNotTriggerErrorNotice

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Debug/ContainerAwareTraceableEventDispatcherTest.php, line 40

Class

ContainerAwareTraceableEventDispatcherTest

Namespace

Symfony\Component\HttpKernel\Tests\Debug

Code

public function testClosureDoesNotTriggerErrorNotice() {
  $container = $this
    ->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
  $dispatcher = new ContainerAwareTraceableEventDispatcher($container, new StopWatch());
  $triggered = false;
  $dispatcher
    ->addListener('onFooEvent', function () use (&$triggered) {
    $triggered = true;
  });
  try {
    $dispatcher
      ->dispatch('onFooEvent');
  } catch (\PHPUnit_Framework_Error_Notice $e) {
    $this
      ->fail($e
      ->getMessage());
  }
  $this
    ->assertTrue($triggered, 'Closure should have been executed upon dispatch');
}