/**
  * @param StaticMethodDefinition|DefinitionInterface $definition
  * @param ContextInterface                           $context
  */
 protected function performTest(DefinitionInterface $definition, ContextInterface $context)
 {
     $className = $definition->getClassName();
     $methodName = $definition->getMethodName();
     if ($definition->getMethodIsPublic()) {
         call_user_func([$className, $methodName], $context);
     } else {
         $method = $definition->getReflectionMethod();
         $method->setAccessible(true);
         $method->invoke(null, $context);
     }
 }
Esempio n. 2
0
 /**
  * @param MethodDefinition|DefinitionInterface $definition
  * @param ContextInterface                     $context
  * @return bool
  */
 protected function performTest(DefinitionInterface $definition, ContextInterface $context)
 {
     $instance = $this->objectManager->create($definition->getClassName());
     $this->invokeSetup($instance);
     $methodName = $definition->getMethodName();
     if ($definition->getMethodIsPublic()) {
         $instance->{$methodName}($context);
     } else {
         $method = $definition->getReflectionMethod();
         $method->setAccessible(true);
         $method->invoke($instance, $context);
     }
 }
Esempio n. 3
0
 /**
  * @param DefinitionInterface $definition
  * @param array               $step
  * @param array               $previousStep
  * @return bool
  */
 private function getTraceStepIsTestMethod(DefinitionInterface $definition, array $step, array $previousStep) : bool
 {
     $filePath = $previousStep['file'] ?? '';
     if ($definition instanceof AbstractMethodDefinition) {
         $functionName = $definition->getMethodName();
     } elseif ($definition instanceof DocCommentCodeDefinition) {
         $functionName = $definition->getRelatedMethodName();
     } else {
         return false;
     }
     if ($filePath === $definition->getFilePath() && $step['function'] === $functionName) {
         return true;
     }
     return false;
 }