public function test_assert_with_event() { $eventer = new Eventer(); $tester = new EventerTester($eventer); $tester->setExpectedEvents(['foo.bar']); $eventer->dispatch('foo.bar'); $tester->assert(); }
/** * @param IContainer $container */ public function __construct(IContainer $container) { $this->setContainer($container); parent::__construct(); }
public function test_invoke_subscriber() { $shared = []; $eventer = new Eventer(); $eventer->subscribe(CustomEvent::class, function (CustomEvent $event) use(&$shared) { $shared[] = 1; }); $eventer->dispatch(new CustomEvent()); $this->assertEquals([1], $shared); $eventer->subscribe(CustomEvent::class, CustomSubscriber::class); $event = new CustomEvent(); $event->setShared($shared); $eventer->dispatch($event); $this->assertEquals([1, 1, 2], $shared); }