mageekguy\atoum\test::__construct PHP Method

__construct() public method

public __construct ( mageekguy\atoum\adapter $adapter = null, annotations\extractor $annotationExtractor = null, asserter\generator $asserterGenerator = null, test\assertion\manager $assertionManager = null, closure $reflectionClassFactory = null, closure $phpExtensionFactory = null, mageekguy\atoum\tools\variable\analyzer $analyzer = null )
$adapter mageekguy\atoum\adapter
$annotationExtractor annotations\extractor
$asserterGenerator asserter\generator
$assertionManager test\assertion\manager
$reflectionClassFactory closure
$phpExtensionFactory closure
$analyzer mageekguy\atoum\tools\variable\analyzer
    public function __construct(adapter $adapter = null, annotations\extractor $annotationExtractor = null, asserter\generator $asserterGenerator = null, test\assertion\manager $assertionManager = null, \closure $reflectionClassFactory = null, \closure $phpExtensionFactory = null, analyzer $analyzer = null)
    {
        $this->setAdapter($adapter)->setPhpFunctionMocker()->setPhpConstantMocker()->setMockGenerator()->setMockAutoloader()->setAsserterGenerator($asserterGenerator)->setAssertionManager($assertionManager)->setTestAdapterStorage()->setMockControllerLinker()->setScore()->setLocale()->setFactoryBuilder()->setReflectionMethodFactory()->setAsserterCallManager()->enableCodeCoverage()->setPhpExtensionFactory($phpExtensionFactory)->setAnalyzer($analyzer);
        $this->observers = new \splObjectStorage();
        $this->extensions = new \splObjectStorage();
        $class = $reflectionClassFactory ? $reflectionClassFactory($this) : new \reflectionClass($this);
        $this->path = $class->getFilename();
        $this->class = $class->getName();
        $this->classNamespace = $class->getNamespaceName();
        if ($annotationExtractor === null) {
            $annotationExtractor = new annotations\extractor();
        }
        $this->setClassAnnotations($annotationExtractor);
        $annotationExtractor->extract($class->getDocComment());
        if ($this->testNamespace === null || $this->testMethodPrefix === null) {
            $annotationExtractor->unsetHandler('ignore')->unsetHandler('tags')->unsetHandler('maxChildrenNumber');
            $parentClass = $class;
            while (($this->testNamespace === null || $this->testMethodPrefix === null) && ($parentClass = $parentClass->getParentClass()) !== false) {
                $annotationExtractor->extract($parentClass->getDocComment());
                if ($this->testNamespace !== null) {
                    $annotationExtractor->unsetHandler('namespace');
                }
                if ($this->testMethodPrefix !== null) {
                    $annotationExtractor->unsetHandler('methodPrefix');
                }
            }
        }
        $this->setMethodAnnotations($annotationExtractor, $methodName);
        $testMethodPrefix = $this->getTestMethodPrefix();
        if ($this->analyzer->isRegex($testMethodPrefix) === false) {
            $testMethodFilter = function ($methodName) use($testMethodPrefix) {
                return stripos($methodName, $testMethodPrefix) === 0;
            };
        } else {
            $testMethodFilter = function ($methodName) use($testMethodPrefix) {
                return preg_match($testMethodPrefix, $methodName) == true;
            };
        }
        foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $publicMethod) {
            $methodName = $publicMethod->getName();
            if ($testMethodFilter($methodName) == true) {
                $this->testMethods[$methodName] = array();
                $annotationExtractor->extract($publicMethod->getDocComment());
                if ($this->methodIsIgnored($methodName) === false && $publicMethod->getNumberOfParameters() > 0 && isset($this->dataProviders[$methodName]) === false) {
                    $this->setDataProvider($methodName);
                }
            }
        }
        $this->runTestMethods($this->getTestMethods());
    }

Usage Example

Beispiel #1
0
 public function __construct(\mageekguy\atoum\adapter $adapter = null, \mageekguy\atoum\annotations\extractor $annotationExtractor = null, \mageekguy\atoum\asserter\generator $asserterGenerator = null, \mageekguy\atoum\test\assertion\manager $assertionManager = null, \closure $reflectionClassFactory = null)
 {
     parent::__construct($adapter, $annotationExtractor, $asserterGenerator, $assertionManager, $reflectionClassFactory);
     $self = $this;
     $this->getAssertionManager()->setHandler('fail', function ($dummy = null) use(&$self) {
         return $self->assert('force fail')->boolean(false)->isTrue();
     });
     $this->getAssertionManager()->setHandler('pass', function ($dummy = null) use(&$self) {
         return $self->assert('force pass')->boolean(true)->isTrue();
     });
     $this->logger = new \Psr\Log\NullLogger();
 }
All Usage Examples Of mageekguy\atoum\test::__construct
test