Example #1
0
File: pho.php Project: ciarand/pho
 *
 * @param \Closure $closure The closure to be ran after the suite
 */
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();
// Exit if necessary
if ($console->getErrorStatus() !== null) {
    exit($console->getErrorStatus());
}
// Load global namespaced functions if required
if (!$console->options['namespace']) {
    $path = realpath(dirname(__FILE__) . '/globalPho.php');
    require_once $path;
}
// Start the runner
Runner::$console = $console;
Runner::getInstance()->run();
Example #2
0
         it('lists the invalid option', function () use(&$printContents) {
             expect($printContents)->toEqual('--invalid is not a valid option' . PHP_EOL);
         });
     });
     context('when an invalid path is used', function () {
         $printContents = null;
         $console = null;
         before(function () use(&$printContents, &$console) {
             $console = new Console(array('./someinvalidpath'), 'php://output');
             ob_start();
             $console->parseArguments();
             $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 () {