Exemplo n.º 1
0
function updateReadme()
{
    $matchersDoc = '';
    $modules = [];
    foreach (ModuleManager::getInstance()->getModules() as $module) {
        $modules[$module->getName()] = $module;
    }
    ksort($modules);
    foreach ($modules as $name => $module) {
        $matchersDoc .= "{$name}\n";
        $matchersDoc .= str_repeat('-', strlen($name)) . "\n\n";
        $matchersDoc .= generateMarkdownList($module);
    }
    $readmeFile = __DIR__ . '/../doc/assertions.rst';
    $readme = file_get_contents($readmeFile);
    $readme = preg_replace('/\\.\\. start matchers.*\\.\\. end matchers/ms', ".. start matchers\n\n{$matchersDoc}\n.. end matchers", $readme);
    file_put_contents($readmeFile, $readme);
}
Exemplo n.º 2
0
 public function __call($words, $args)
 {
     if (null !== $words) {
         $this->syntax .= strtolower(preg_replace('/([A-Z])/', ' $1', $words)) . ' ';
     }
     if (count($args) > 0) {
         $this->data[] = $args[0];
         $this->syntax .= '? ';
     }
     try {
         $syntax = ModuleManager::getInstance()->getSyntaxCache()->getSyntax($this->getSyntax());
     } catch (Exception $e) {
         $syntax = null;
     }
     if ($syntax) {
         self::$lastBuilder = null;
         $class = $syntax->getClass();
         /** @var AbstractModule $instance */
         $instance = new $class();
         $data = $this->getData();
         $types = $syntax->getArgumentTypes();
         $checker = new DataTypeChecker();
         for ($i = 0; $i < count($types); ++$i) {
             try {
                 $data[$i] = $checker->check($types[$i], $data[$i]);
             } catch (DataTypeMismatchException $e) {
                 $renderer = new ValueRenderer();
                 throw new Exception("Argument " . ($i + 1) . ' (' . $renderer->render($data[$i]) . ') must be ' . implode(' or ', $types[$i]) . '.');
             }
         }
         $instance->setData($data);
         $instance->syntax = $syntax;
         try {
             $instance->{$syntax->getMethod()}();
             $this->testCase->assertTrue(true);
         } catch (DidNotMatchException $e) {
             $this->handleFailure($e, $instance);
         }
     }
     return $this;
 }
Exemplo n.º 3
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $modules = array(new ArrayModule(), new BasicModule(), new BooleanModule(), new DateAndTimeModule(), new ExceptionModule(), new FileModule(), new HashModule(), new NumberModule(), new ObjectModule(), new RegularExpressionModule(), new StringModule(), new TypeModule(), new UrlModule());
     foreach ($modules as $module) {
         ModuleManager::getInstance()->loadModule($module);
     }
 }
Exemplo n.º 4
0
 public function testGetModules()
 {
     $this->assert($this->parser->getModules())->isAnArray;
 }