public function testNotifyUntil() { $name = 'test.listener'; $mocks = array(); $listeners = array(); for ($i = 0; $i < 4; $i++) { $mocks[$i] = $this->getMock('IMockListener'); $listeners[$i] = array($mocks[$i], 'testCallback'); $this->dispatcher->attach($name, $listeners[$i]); } $this->assertThat($listeners, $this->equalTo($this->dispatcher->getListeners($name)), 'Both listener arrays must are equal'); $e = new Event(null, $name); $mocks[0]->expects($this->once())->method('testCallback'); $mocks[1]->expects($this->once())->method('testCallback')->will($this->returnValue(true)); $mocks[2]->expects($this->never())->method('testCallback'); $mocks[3]->expects($this->never())->method('testCallback'); // notifies only first 2 mocks, other 2 mocks are not called $this->dispatcher->notifyUntil($e, true); }