public function testHistoryHasExecutedCommands()
 {
     $message = 'wow';
     $cmd1 = $this->createChainableCommand();
     $this->dispatcher->handleCommands(array($cmd1), $message);
     $history = $this->dispatcher->getHistory();
     $this->assertEquals(array($cmd1), $history);
 }
        $message = $inputs[0];
        if (stristr($message, self::OBJECTIVE)) {
            $this->attackStatus = true;
        }
        return $this->attackStatus;
    }
    public function preLog(LoggerInterface $logger)
    {
    }
    public function postLog(LoggerInterface $logger)
    {
        $logger->info(sprintf('3. Updated the attack status to: "%s"', $this->attackStatus ? 'ATTACK!' : 'NO ATTACK'));
    }
}
$logger = new Logger('test', array(new TestHandler()));
$dispatcher = new ChainDispatcher();
$dispatcher->addPreCommandHandler(function ($cmd) use($logger) {
    $cmd->preLog($logger);
});
$dispatcher->addPostCommandHandler(function ($cmd) use($logger) {
    $cmd->postLog($logger);
});
$encryptedMessages = array(new SecretMessage('Yomimoto', str_rot13('Sun rises from the east!')), new SecretMessage('Nagumo', str_rot13('No climbing today')), new SecretMessage('Nagumo', str_rot13('Climb Mt. Niitaka!')));
foreach ($encryptedMessages as $message) {
    try {
        $dispatcher->handleCommands(array(CatchMessageCommand::create(), DecryptMessageCommand::create(), AttackDecisionCommand::create()), $message);
    } catch (\Exception $e) {
        $logger->info(sprintf('Abort: %s', $e->getMessage()));
    }
}
$records = $logger->popHandler()->getRecords();