Example #1
0
    def testHasListenersOnLazyLoad(self):

        event = Event();

        service = Service();

        container = Container();
        container.set('service.listener', service);

        dispatcher = ContainerAwareEventDispatcher(container);
        dispatcher.addListenerService('onEvent', ['service.listener', 'onEvent']);

        event.setDispatcher(dispatcher);
        event.setName('onEvent');

        self.assertTrue(dispatcher.hasListeners());

        if (dispatcher.hasListeners('onEvent')) :
            dispatcher.dispatch('onEvent');
Example #2
0
    def testRemoveBeforeDispatch(self):

        event = Event();

        service = Service();

        container = Container();
        container.set('service.listener', service);

        dispatcher = ContainerAwareEventDispatcher(container);
        dispatcher.addListenerService('onEvent', ['service.listener', 'onEvent']);

        dispatcher.removeListener('onEvent', [container.get('service.listener'), 'onEvent']);
        self.assertFalse(dispatcher.hasListeners('onEvent'));