You don't. It's a unit test. You don't care about what happens outside your unit. You just trust what your code executes, and verify that an event is triggered.
Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 22 October 2013 16:44, Norbert Máté <[email protected]> wrote: > Marco, could you please finish the example. In the with you give the > parameters for the trigger method and that's all? > > This way you just trigger an event. Am I wrong? > How do you know if the event was caught? > > Thanks, > Norbert. > > > On 5 October 2013 20:08, Marco Pivetta <[email protected]> wrote: > >> Also wrong =D >> >> @julian use a real mock! >> >> $em = $this->getMock('Zend\\EventManager\\EventManagerInterface'); >> $em->expects($this->once())->method('trigger')->with(...); >> >> That should be the proper way :) >> On 5 Oct 2013 18:39, "Artur Bodera" <[email protected]> wrote: >> >> > On Thu, Oct 3, 2013 at 5:48 PM, Julian Vidal <[email protected]> >> > wrote: >> > >> > > $eventManager->attach('mymethod.post', function() { >> > > $this->assertTrue(true); >> > > }); >> > > >> > >> > This is wrong, because if it doesn't get fired, the test will also pass. >> > >> > You can do something like this: >> > >> > $wasFired = false; >> > $eventManager->attach('mymethod.post', function() use (&$wasFired) { >> > $wasFired = true; >> > }); >> > $this->assertTrue($wasFired); >> > >> > >> > >> > -- >> > [email protected] >> > +48 695 600 936 >> > http://thinkscape.pro >> > >> > >
