context('when reporter not found', function () { before(function () { $this->console = new Console(['-r', 'unkown'], 'php://output'); $this->console->parseArguments(); }); it('throw pho\\Exception\\ReporterNotFoundException exception', function () { expect(function () { $this->console->getReporterClass(); })->toThrow('pho\\Exception\\ReporterNotFoundException'); }); }); }); context('write', function () { it('prints the text to the terminal', function () { $write = function () { $console = new Console([], 'php://output'); $console->write('test'); }; expect($write)->toPrint('test'); }); }); context('writeLn', function () { it('prints the text, followed by a newline, to the terminal', function () { $writeLn = function () { $console = new Console([], 'php://output'); $console->writeLn('test'); }; expect($writeLn)->toPrint('test' . PHP_EOL); }); }); });
} // Exit if necessary if ($console->getExitStatus() !== null) { exit($console->getExitStatus()); } // Load global namespaced functions if required if (!$console->options['namespace']) { $path = dirname(__FILE__) . '/globalPho.php'; require_once $path; } // Bootstrap file must be required directly rather than from function // invocation to preserve any loaded globals $bootstrap = $console->options['bootstrap']; if ($bootstrap) { if (!file_exists($bootstrap)) { $console->writeLn("Bootstrap file not found: {$bootstrap}"); exit(1); } else { if (!is_readable($bootstrap)) { $console->writeLn("Bootstrap file not readable: {$bootstrap}"); exit(1); } else { if (!@(include_once $bootstrap)) { $console->writeLn("Unable to include bootstrap: {$bootstrap}"); exit(1); } } } } // Files must be required directly rather than from function // invocation to preserve any loaded globals