Exemplo n.º 1
0
 private function newTestMethod($filePath, $className, ReflectionMethod $method, DocCommentParser $dcp)
 {
     $testMethod = new TestMethod();
     $testMethod->setClassFilePath($filePath)->setClassName($className);
     $expectedInputArgumentNames = array_map(function ($parameter) {
         return $parameter->getName();
     }, $method->getParameters());
     $testMethod->setExpectedInputArgumentNames($expectedInputArgumentNames);
     $testMethod->setName($method->getName());
     if ($dcp->hasOption('depends')) {
         $on = array_reverse($dcp->getArrayOption('depends'));
         foreach ($on as $offset => $methodName) {
             if (!empty($expectedInputArgumentNames)) {
                 $argumentName = $expectedInputArgumentNames[count($expectedInputArgumentNames) - 1 - $offset];
             } else {
                 $argumentName = null;
             }
             $testMethod->setDependency($argumentName, $methodName);
         }
     }
     if ($dcp->hasOption('expectedException')) {
         $expectedException = $dcp->getOption('expectedException');
         $testMethod->setExpectedException($expectedException);
     }
     return $testMethod;
 }
Exemplo n.º 2
0
 public function fromArray(array $arr)
 {
     foreach ($arr['testables'] as $testable) {
         $testMethod = new TestMethod();
         $testMethod->fromArray($testable);
         $this->addTestMethod($testMethod);
     }
     $this->classFilePath = $arr['classFilePath'];
     $this->className = $arr['className'];
     $this->isExecutionPlan = $arr['isExecutionPlan'];
     return $this;
 }