Example #1
0
 public function test_assert_with_event()
 {
     $eventer = new Eventer();
     $tester = new EventerTester($eventer);
     $tester->setExpectedEvents(['foo.bar']);
     $eventer->dispatch('foo.bar');
     $tester->assert();
 }
Example #2
0
 /**
  * @param IContainer $container
  */
 public function __construct(IContainer $container)
 {
     $this->setContainer($container);
     parent::__construct();
 }
Example #3
0
 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);
 }