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 $paths = expandPaths($console->getPaths()); foreach ($paths as $path) { require_once $path; } // Start the runner Runner::$console = $console; Runner::getInstance()->run(); exit($console->getExitStatus());
ob_end_clean(); $this->console = $console; }); it('sets the error status to 1', function () { expect($this->console->getExitStatus())->toEqual(1); }); it('lists the invalid path', function () { expect($this->printContents)->toEqual("The file or path \"./someinvalidpath\" doesn't exist" . PHP_EOL); }); }); }); context('getPaths', function () { it('returns the array of parsed paths', function () { $console = new Console(['./'], 'php://output'); $console->parseArguments(); expect($console->getPaths())->toEqual(['./']); }); }); context('getReporterClass', function () { it('returns DotReporter by default', function () { $console = new Console([], 'php://output'); $console->parseArguments(); $expectedClass = 'pho\\Reporter\\DotReporter'; expect($console->getReporterClass())->toEqual($expectedClass); }); it('returns a valid reporter specified in the args', function () { $console = new Console(['-r', 'spec'], 'php://output'); $console->parseArguments(); $expectedClass = 'pho\\Reporter\\SpecReporter'; expect($console->getReporterClass())->toEqual($expectedClass); });
$printContents = ob_get_contents(); ob_end_clean(); }); it('sets the error status to 1', function () use(&$console) { expect($console->getErrorStatus())->toEqual(1); }); it('lists the invalid path', function () use(&$printContents) { expect($printContents)->toEqual("The file or path \"./someinvalidpath\" doesn't exist" . PHP_EOL); }); }); }); context('getPaths', function () { it('returns the array of parsed paths', function () { $console = new Console(array('./'), 'php://output'); $console->parseArguments(); expect($console->getPaths())->toEqual(array('./')); }); }); context('getReporterClass', function () { it('returns DotReporter by default', function () { $console = new Console(array(), 'php://output'); $console->parseArguments(); $expectedClass = 'pho\\Reporter\\DotReporter'; expect($console->getReporterClass())->toEqual($expectedClass); }); it('returns a valid reporter specified in the args', function () { $console = new Console(array('-r', 'spec'), 'php://output'); $console->parseArguments(); $expectedClass = 'pho\\Reporter\\SpecReporter'; expect($console->getReporterClass())->toEqual($expectedClass); });