Example #1
0
 /**
  * Tests firing named events from the collection
  * @return void
  */
 public function testFireEvent()
 {
     $collection = new Collection();
     $mock = $this->getMock('Tests\\Lib\\Nimbles\\Core\\Event\\ListenerMock');
     $collection->connect('event1', array($mock, 'listen1'));
     $collection->connect('event1', array($mock, 'listen2'));
     $collection->connect('event2', array($mock, 'listen2'));
     $collection->connect('event2', array($mock, 'listen3'));
     $mock->expects($this->once())->method('listen1')->with($this->isInstanceOf('Nimbles\\Core\\Event'));
     $mock->expects($this->exactly(2))->method('listen2')->with($this->isInstanceOf('Nimbles\\Core\\Event'));
     $mock->expects($this->once())->method('listen3')->with($this->isInstanceOf('Nimbles\\Core\\Event'), $this->equalTo('hello'));
     $collection->fireEvent('event1');
     $collection->fireEvent('event2', 'hello');
 }