Esempio n. 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     $finder = new Finder();
     $finder->files()->in($path);
     foreach ($finder as $file) {
         $filePath = $file->getRealpath();
         Suite::$filePath = $filePath;
         include $filePath;
     }
     $errors = Suite::getErrors();
     if (count($errors) == 0) {
         $output->writeln("<fg=black;bg=green>No Errors (" . Suite::$describeCount . " describes)</fg=black;bg=green>");
     } else {
         $i = 0;
         foreach ($errors as $error) {
             $i++;
             $output->writeln("<error>Error #{$i} {$error->getName()}</error>");
             $output->writeln("<error>" . $error->getException()->getMessage() . "</error>");
             $output->writeln(" at file: {$error->getFile()} in line {$error->getLine()}");
             foreach ($error->getParameters() as $k => $v) {
                 $output->writeln("  {$k}: {$v}");
             }
             $output->writeln("");
         }
         $output->writeln("");
         $output->writeln("<error>{$i} Errors detected (" . Suite::$describeCount . " describes)</error>");
     }
 }
Esempio n. 2
0
function describe($name, callable $callback, $provider = null)
{
    if (is_null($provider)) {
        try {
            Suite::$parameters = [];
            Suite::$describeCount++;
            call_user_func($callback);
        } catch (\PHPUnit_Framework_Exception $e) {
            Suite::appendError(new Error($name, $e));
        }
    } else {
        foreach ($provider as $providerItem) {
            try {
                Suite::$parameters = $providerItem;
                Suite::$describeCount++;
                call_user_func_array($callback, $providerItem);
            } catch (\PHPUnit_Framework_Exception $e) {
                Suite::appendError(new Error($name, $e));
            }
        }
    }
}