public function run(PHPUnit_Framework_TestResult $result = null) { if ($result === null) { $result = $this->createResult(); } ConciseReporter::$test = $this; ConciseReporter::$testCase = new IndependentTestCase(); ConciseReporter::$result = $result; // Create a new Console and parse arguments $console = new Console(array('--reporter', 'concise'), 'php://stdout'); $console->parseArguments(); // Start the runner Runner::$console = $console; Runner::getInstance()->run(); return $result; }
<?php use pho\Runnable\Spec; use pho\Suite\Suite; use pho\Reporter\SpecReporter; use pho\Reporter\ReporterInterface; use pho\Console\Console; describe('SpecReporter', function () { $console = null; $spec = null; before(function () use(&$console, &$spec) { $console = new Console(array(), 'php://output'); $console->parseArguments(); $suite = new Suite('test', function () { }); $spec = new Spec('testspec', function () { }, $suite); }); it('implements the ReporterInterface', function () use(&$console) { $reporter = new SpecReporter($console); expect($reporter instanceof ReporterInterface)->toBeTrue(); }); context('beforeSuite', function () use(&$console) { $reporter = null; before(function () use(&$console, &$reporter) { $reporter = new SpecReporter($console); }); it('prints the suite title', function () use(&$reporter) { $beforeSuite = function () use(&$reporter) { $suite = new Suite('test suite', function () { });
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); }); }); });
*/ function afterEach(\Closure $closure) { Runner::getInstance()->afterEach($closure); } /** * Creates and returns a new Expectation for the supplied value. * * @param mixed $actual The value to test */ function expect($actual) { return new Expectation($actual); } // Create a new Console and parse arguments $console = new Console(array_slice($argv, 1), 'php://stdout'); $console->parseArguments(); // Disable color output if necessary if ($console->options['no-color']) { $console->formatter->disableANSI(); } // 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; } // Start the runner
if (is_file($path)) { array_push($expanded, $path); continue; } $path = realpath($path); $dirIterator = new \RecursiveDirectoryIterator($path); $iterator = new \RecursiveIteratorIterator($dirIterator); $files = new \RegexIterator($iterator, '/^.+Spec\\.php$/i', \RecursiveRegexIterator::GET_MATCH); foreach ($files as $filename => $file) { array_push($expanded, $filename); } } return $expanded; } // Create a new Console and parse arguments $console = new Console(array_slice($argv, 1), 'php://stdout'); $console->parseArguments(); // Disable color output if necessary if ($console->options['no-color']) { $console->formatter->disableANSI(); } // 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