Beispiel #1
0
 public function testEventCallbacks()
 {
     $et = new ET();
     $et->c = 0;
     $inc_c = function () use($et) {
         $et->c++;
     };
     $checker = function ($event) {
         return $event->name === 'ok';
     };
     // test checker
     $et->on($checker, $inc_c);
     $et->emit('ok');
     $et->emit('nope');
     $this->assertSame($et->c, 1);
     // test removal
     $et->removeListener($checker, $inc_c);
     $et->emit('ok');
     $this->assertSame($et->c, 1);
     // test removeAllListeners
     $et->on($checker, $inc_c);
     $et->emit('ok');
     $this->assertSame($et->c, 2);
     $et->removeAllListeners($checker);
     $et->emit('ok');
     $this->assertSame($et->c, 2);
 }