'L{_ThreePhaseEvent.fireEvent} should wait for any L{Deferred} returned
by a I{before} phase trigger before proceeding to I{during} events.'

def test_asynchronousBefore(self):

    events = []
    beforeResult = Deferred()
    self.event.addTrigger('before', (lambda : beforeResult))
    self.event.addTrigger('during', events.append, 'during')
    self.event.addTrigger('after', events.append, 'after')
    self.assertEqual(events, [])
    self.event.fireEvent()
    self.assertEqual(events, [])
    beforeResult.callback(None)
    self.assertEqual(events, ['during', 'after'])
