$dispatcher->
addSubscriber($handler);
$dispatcher->
addListener(ConsoleEvents::COMMAND,
function D
) use ($logger) { $logger->
info('After command message.'
);
});
$dispatcher->
addListener(ConsoleEvents::TERMINATE,
function D
) use ($logger) { $logger->
info('After terminate message.'
);
});
$event =
new ConsoleCommandEvent(new Command('foo'
),
$this->
createMock(InputInterface::
class),
$output);
$dispatcher->
dispatch($event, ConsoleEvents::COMMAND
);
$this->
assertStringContainsString('Before command message.',
$out =
$output->
fetch());
$this->
assertStringContainsString('After command message.',
$out);
$event =
new ConsoleTerminateEvent(new Command('foo'
),
$this->
createMock(InputInterface::
class),
$output, 0
);
$dispatcher->
dispatch($event, ConsoleEvents::TERMINATE
);
$this->
assertStringContainsString('Before terminate message.',
$out =
$output->
fetch());
$this->
assertStringContainsString('After terminate message.',
$out);
}}