/** * @param TestData $data * @param string $shortClassName * @param ReflectionParameter $parameter * @param string $variableName * @param array $variableList */ private function processMethod(TestData $data, string $shortClassName, ReflectionParameter $parameter, string $variableName, &$variableList) { $value = 'null'; if ($parameter->isOptional()) { $value = $parameter->getDefaultValue(); } if ($parameter->getClass()) { $class = $parameter->getClass()->name; $data->addUse($class); $value = sprintf('new %s()', $shortClassName); } $variableList[] = sprintf("\t\t%s = %s;", $variableName, $value); }
/** * @param Definition $referenceService * @param TestData $testData * @param string $mockName */ public function addMock(Definition $referenceService, TestData $testData, $mockName) { $class = $referenceService->getClass(); $testData->addUse($class); $mock = sprintf("\t\t\$this->%s = \$this->createMock(%s::class);", lcfirst($mockName), $mockName); $testData->localMocks[] = $mock; $testData->mockProperties[] = sprintf("\t/**\n\t * @var %s|MockObject\n\t */\n\tprivate \$%s;\n", $mockName, lcfirst($mockName)); }