function testListeners() { $ee = new EventEmitter(); $callback1 = function () { }; $callback2 = function () { }; $ee->on('foo', $callback1, 200); $ee->on('foo', $callback2, 100); $this->assertEquals([$callback2, $callback1], $ee->listeners('foo')); }
public function testOffMulti() { $closure = function () { }; $closure1 = function () { }; $this->event->on(array('a', 'b'), $closure); $this->event->addListener(array('a', 'b'), $closure1); $this->assertEquals(array($closure, $closure1), $this->event->listeners('a')); $this->assertEquals(array($closure, $closure1), $this->event->listeners('b')); $this->event->off(array('a', 'b'), $closure); $this->assertEquals(array(1 => $closure1), $this->event->listeners('a')); $this->assertEquals(array(1 => $closure1), $this->event->listeners('b')); }
function testWildcardListeners() { $ee = new EventEmitter(); $callback1 = function () { }; $callback2 = function () { }; $callback3 = function () { }; $ee->on('foo.*', $callback1); $ee->on('foo.bar', $callback2); $ee->on('foo.qux', $callback3); $this->assertEquals([$callback1, $callback2], $ee->listeners("foo.bar")); }