/** * @param CodeDefinitionInterface|DefinitionInterface $definition * @param ContextInterface $context */ protected function performTest(DefinitionInterface $definition, ContextInterface $context) { $preprocessedCode = $definition->getPreProcessedCode(); if (!$preprocessedCode || $preprocessedCode === ';') { $this->printer->warn('No test code given'); } $this->evaluate($preprocessedCode, $context); }
/** * @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); } }
/** * @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); } }
/** * @param DefinitionInterface $definition * @param \Throwable $exception * @return string */ private function getTestLocationForDefinitionAndException(DefinitionInterface $definition, $exception) : string { if ($exception instanceof AssertionError) { return $definition->getFilePath(); } return $exception->getFile() . ' at ' . $exception->getLine(); }
/** * @param DefinitionInterface $definition */ private function prepareTestRunnerForDefinition(DefinitionInterface $definition) { if ($definition->getClassName()) { $this->classLoader->loadClass($definition->getClassName(), $definition->getFile()); } }