mageekguy\atoum\test::setMethodAnnotations PHP Method

setMethodAnnotations() protected method

protected setMethodAnnotations ( annotations\extractor $extractor, &$methodName )
$extractor annotations\extractor
    protected function setMethodAnnotations(annotations\extractor $extractor, &$methodName)
    {
        $test = $this;
        $extractor->resetHandlers()->setHandler('ignore', function ($value) use($test, &$methodName) {
            $test->ignoreMethod($methodName, annotations\extractor::toBoolean($value));
        })->setHandler('tags', function ($value) use($test, &$methodName) {
            $test->setMethodTags($methodName, annotations\extractor::toArray($value));
        })->setHandler('dataProvider', function ($value) use($test, &$methodName) {
            $test->setDataProvider($methodName, $value === true ? null : $value);
        })->setHandler('engine', function ($value) use($test, &$methodName) {
            $test->setMethodEngine($methodName, $value);
        })->setHandler('isVoid', function ($value) use($test, &$methodName) {
            $test->setMethodVoid($methodName);
        })->setHandler('isNotVoid', function ($value) use($test, &$methodName) {
            $test->setMethodNotVoid($methodName);
        })->setHandler('php', function ($value) use($test, &$methodName) {
            $value = annotations\extractor::toArray($value);
            if (isset($value[0]) === true) {
                $operator = null;
                if (isset($value[1]) === false) {
                    $version = $value[0];
                } else {
                    $version = $value[1];
                    switch ($value[0]) {
                        case '<':
                        case '<=':
                        case '=':
                        case '==':
                        case '>=':
                        case '>':
                            $operator = $value[0];
                    }
                }
                $test->addMethodPhpVersion($methodName, $version, $operator);
            }
        })->setHandler('extensions', function ($value) use($test, &$methodName) {
            foreach (annotations\extractor::toArray($value) as $mandatoryExtension) {
                $test->addMandatoryMethodExtension($methodName, $mandatoryExtension);
            }
        });
        return $this;
    }

Usage Example

Beispiel #1
0
 protected function setMethodAnnotations(annotations\extractor $extractor, &$methodName)
 {
     parent::setMethodAnnotations($extractor, $methodName);
     $test = $this;
     $tagHandler = function ($value) use($test, &$methodName) {
         $test->setMethodTags($methodName, annotations\extractor::toArray($value));
     };
     $extractor->setHandler('author', $tagHandler)->setHandler('expectedException', function ($value) use($test, &$methodName) {
         if ($value) {
             $test->addUnsupportedMethod($methodName, '@expectedException is not supported.');
         }
     })->setHandler('group', $tagHandler)->setHandler('large', function () use($tagHandler) {
         $tagHandler('large');
     })->setHandler('medium', function () use($tagHandler) {
         $tagHandler('medium');
     })->setHandler('runInSeparateProcess', function () use($test, &$methodName) {
         $test->setMethodEngine($methodName, 'isolate');
     })->setHandler('small', function () use($tagHandler) {
         $tagHandler('small');
     });
     return $this;
 }
test