Is it able to test output twice?
This is the code
<?php
public function testAutoTriggerOff()
{
$user = array(
'id'=>1,
'name'=>'Andy',
'logTime'=> time()
);
$this->elevent->turnOffAutoTrigger();
$this->elevent->attach('Elevent\Test\Event\UserHasLoggedIn', new WelcomeUser);
$event = $this->elevent->setEvent('Elevent\Test\Event\UserHasLoggedIn', $user);
$this->expectOutputString('');
$this->elevent->trigger($event);
$this->expectOutputString('Welcome, Andy');
}
So, after the setEvent is called, I want to test that there is no outputâŚ
And, after the trigger is called, I want to test that the output is âWelcome, Andyâ
This test passed.
However, if I changed the first test output into something that should be false, such as
$this->expectOutputString('this one should be false');
$this->elevent->trigger($event);
$this->expectOutputString('Welcome, Andy');
But, the test also passed. I expected it to fail, since I want to test the output twice.
Before the trigger, it should give no output.
After the trigger, the output should be âWelcome, Andyâ
How to test that way?
N.B.
In this case, I test if auto-trigger is really off⌠If the auto-trigger is off, I need to call the trigger method to fire the listener⌠If itâs on, I donât need to call the trigger, itâs auto-triggered since the event is setâŚ