/** * Generate code to cache from class reflection. * * @todo maybe move some of this into Zend\Code * * @param ClassReflection $classReflection * @return string */ public function getCacheCode(ClassReflection $classReflection) { $useString = $this->fileReflectionService->getUseString($classReflection->getDeclaringFile()); $declaration = $this->classDeclarationService->getClassDeclaration($classReflection); $classContents = $classReflection->getContents(false); $classFileDir = dirname($classReflection->getFileName()); $classContents = trim(str_replace('__DIR__', sprintf("'%s'", $classFileDir), $classContents)); $return = "\nnamespace " . $classReflection->getNamespaceName() . " {\n" . $useString . $declaration . "\n" . $classContents . "\n}\n"; return $return; }
public function testBasicClass() { Phake::when($this->classTypeService)->getClassType(Phake::anyParameters())->thenReturn('class '); Phake::when($this->mockClassReflection)->getShortName()->thenReturn('BasicTest'); $this->assertEquals('class BasicTest', $this->sut->getClassDeclaration($this->mockClassReflection)); }