/**
* @covers FOF30\Event\Dispatcher::chainHandle
*/
public function testChainHandle()
{
ReflectionHelper::setValue($this->object, 'observers', array());
ReflectionHelper::setValue($this->object, 'events', array());
$observer1 = new FirstObserver($this->object);
$observer2 = new SecondObserver($this->object);
// Trigger a non-existent event
$result = $this->object->chainHandle('notthere');
$this->assertNull($result);
// Trigger a non-existent event with data
$result = $this->object->chainHandle('notthere', array('whatever', 'nevermind'));
$this->assertNull($result);
// Trigger an event with one observer responding to it
$result = $this->object->chainHandle('onlySecond');
$this->assertEquals('only second', $result);
// Trigger an event with two observers responding to it
$result = $this->object->chainHandle('identifyYourself');
$this->assertEquals('one', $result);
// Trigger an event with two observers responding to it, with parameters
$result = $this->object->chainHandle('returnConditional', array('one'));
$this->assertEquals(true, $result);
// Trigger an event with two observers responding to it, with parameters
$result = $this->object->chainHandle('returnConditional', array('two'));
$this->assertEquals(false, $result);
// Trigger a real chain handler
$result = $this->object->chainHandle('chain', array('one'));
$this->assertEquals('one', $result);
// Trigger a real chain handler
$result = $this->object->chainHandle('chain', array('two'));
$this->assertEquals('two', $result);
}