Example #1
0
 static function import(Registry $registry, $in, $allowIncomplete = false)
 {
     props:
     if (isset($in['props'])) {
         foreach ($in['props'] as &$item) {
             if ($item !== true) {
                 if (isset($item['check']) || $item instanceof \Fulfil\CheckInterface) {
                     $item = [$item];
                 }
                 if (is_array($item)) {
                     $new = [];
                     foreach ($item as $k => $check) {
                         if ($check instanceof \Fulfil\CheckInterface) {
                             $new[$k] = $check;
                         } else {
                             $new[$k] = $registry->import('check', $check, $allowIncomplete);
                         }
                     }
                     $item = $new;
                 }
             }
         }
     }
     rules:
     if (isset($in['rules'])) {
         foreach ($in['rules'] as &$item) {
             $item = $registry->import('rule', $item, $allowIncomplete);
         }
     }
     return parent::import($registry, $in, $allowIncomplete);
 }
Example #2
0
 static function import(Registry $registry, $in, $allowIncomplete = false)
 {
     schemas:
     if (isset($in['schemas'])) {
         $schemas =& $in['schemas'];
         if (isset($schemas['check'])) {
             $schemas = [$schemas];
         }
         foreach ($schemas as &$item) {
             $item = $registry->import('check', $item, $allowIncomplete);
         }
     }
     rules:
     if (isset($in['rules'])) {
         foreach ($in['rules'] as &$item) {
             $item = $registry->import('rule', $item, $allowIncomplete);
         }
     }
     return parent::import($registry, $in, $allowIncomplete);
 }
Example #3
0
 static function import(Registry $registry, $in, $allowIncomplete = false)
 {
     if (isset($in['checks'])) {
         foreach ($in['checks'] as &$item) {
             if (!$item instanceof \Fulfil\CheckInterface) {
                 $item = $registry->import('check', $item, $allowIncomplete);
             }
         }
     }
     return parent::import($registry, $in, $allowIncomplete);
 }
Example #4
0
 static function import(\Fulfil\Registry $registry, $in, $allowIncomplete = false)
 {
     $in['specTest'] = true;
     if (isset($in['test']['check'])) {
         $in['test'] = [$in['test']];
     }
     if (isset($in['test'])) {
         foreach ($in['test'] as &$test) {
             if (!isset($test['check'])) {
                 throw new \Exception();
             }
             $test = $registry->import('check', $test, $allowIncomplete);
         }
         unset($test);
     }
     if (isset($in['data'])) {
         foreach ($in['data'] as $k => $i) {
             $i['specTest'] = 'case';
             $i = $registry->import('specTest', $i, $allowIncomplete);
             $in['data'][$k] = $i;
         }
     }
     return parent::import($registry, $in, $allowIncomplete);
 }
Example #5
0
 function testUnknownRuleImportFailsWhenIncompleteDisallowed()
 {
     $registry = new Registry();
     $this->setExpectedException(\InvalidArgumentException::class, 'Unknown rule');
     $registry->import('rule', ['rule' => 'whabadoo']);
 }