/** * * @param \Box\TestScribe\PHPDoc\IPhpDoc $typeInfo * @param string $subject * The description of the target that is to receive the value * @param string $className '' if the class under test * @param string $methodName * @param string $paramName * * @return \Box\TestScribe\Input\InputValue */ public function get(IPhpDoc $typeInfo, $subject, $className, $methodName, $paramName) { // Should this method pause the output? $shouldPause = true; $isClass = $typeInfo->isClass(); if ($isClass) { $className = $typeInfo->getRepresentation(); // Automatically mock the class in this simple case for convenience // by automatically generating an expression that uses this className. // The assumption is that that class name returned here is a // fully qualified name which starts with '\'. $expression = ClassNameUtil::getNormalizedFullyQualifiedClassName($className); } else { if ($typeInfo->isVoid()) { $expression = 'void'; } else { // The output is paused already prompting users for input. $shouldPause = false; // @TODO (ryang 1/9/15) : allow users to retry when they make a typo. // @TODO (ryang 1/9/15) : validate against the type $typeString = $typeInfo->getRepresentation(); $subjectWithTypeInfo = "{$subject} of the data type ( {$typeString} )"; $expression = $this->inputWithHistory->getInputValue($subjectWithTypeInfo, $className, $methodName, $paramName); } } $inputValue = $this->stringToInputValueConverter->getValue($expression); if ($shouldPause) { $this->inputWithHistory->pause(); } return $inputValue; }
/** * @covers Box\TestScribe\Utils\ClassNameUtil::getNormalizedFullyQualifiedClassName */ public function testGetNormalizedFullyQualifiedClassNameStartWithBackSlash() { $executionResult = \Box\TestScribe\Utils\ClassNameUtil::getNormalizedFullyQualifiedClassName('\\foo\\bar'); $expected = '\\foo\\bar'; $this->assertSame($expected, $executionResult, 'Variable ( executionResult ) doesn\'t have the expected value.'); }