public function testAlreadyMarkedClassGetsNotMarked()
 {
     $gClass = new GClass('MarkedClass');
     $gClass->createDocBlock()->addAnnotation(\Psc\Code\Compile\Annotations\Compiled::create());
     // erstellen hier darf jetzt keine neue annotation in out erstellen
     $ext = new MarkCompiledExtension();
     $ext->compile($gClass);
     $this->assertCount(1, $gClass->getDocBlock()->getAnnotations('Psc\\Code\\Compile\\Annotations\\Compiled'), 'Anzahl der @Compiled Annotations ist falsch!');
 }
Esempio n. 2
0
 public function compile(GClass $gClass, $flags = 0x0)
 {
     $c = 'Psc\\Code\\Compile\\Annotations\\Compiled';
     if (!$gClass->hasDocBlock() || !$gClass->getDocBlock()->hasAnnotation($c)) {
         // @FIXME hasAnnotation kann falsch sein!
         /* erstelle einen DocBlock / modifiziere den DocBlock von gClass */
         if (!$gClass->hasDocBlock()) {
             $gClass->createDocBlock();
         }
         $gClass->getDocBlock()->addAnnotation($c::create());
     }
 }
Esempio n. 3
0
 public function createStub(GClass $class)
 {
     $setupCode = "\$this->chainClass = '%s';\n";
     $setupCode .= "parent::setUp();\n";
     if ($this->class->isAbstract()) {
         $setupCode .= '//$this->%s = $this->getMockForAbstractClass($this->chainClass);' . "\n";
     } else {
         $setupCode .= "//\$this->%s = new %s();\n";
     }
     $docBlock = $class->createDocBlock();
     $docBlock->addSimpleAnnotation('group class:' . $this->class->getFQN());
     $class->addMethod(new GMethod('setUp', array(), sprintf($setupCode, $this->class->getFQN(), lcfirst($this->class->getClassName()), $this->class->getClassName())));
     $class->addMethod(new GMethod('testAcceptance', array(), '$this->markTestIncomplete(\'Stub vom Test-Creater\');'));
     //$class->addMethod(new GMethod('create'.$this->class->getClassName(), array(),
     //sprintf("return new %s();",$this->class->getClassName())), GMethod::MODIFIER_PROTECTED);
     $class->createProperty(lcfirst($this->class->getClassName()), GProperty::MODIFIER_PROTECTED);
     return $class;
 }
Esempio n. 4
0
 public function createClassMetadata(GClass $gClass)
 {
     // da wir gClass mehrmals im Test evalen könnten, erzeugen wir einen unique hash für den classname und übergeben den
     // der class metadata
     $className = uniqid($gClass->getClassName());
     $gClass->setClassName($className);
     $gClass->createDocBlock()->addAnnotation(Annotation::createDC('Entity'));
     $classWriter = new ClassWriter($gClass);
     $classWriter->setUseStyle('lines');
     $classWriter->addImport(new GClass('Doctrine\\ORM\\Mapping'), 'ORM');
     // braucht einen AnnotationReader nicht SimpleAnnotationReader
     $classWriter->write($file = $this->newFile('entity.' . $gClass->getClassName() . '.php'));
     require $file;
     $cm = new ClassMetadata($gClass->getFQN());
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $this->annotationDriver->loadMetadataForClass($gClass->getFQN(), $cm);
     $file->delete();
     return $cm;
 }
Esempio n. 5
0
    public function testDocBlock()
    {
        $gClass = new GClass('Psc\\XML\\TestObjects\\Bla');
        $gClass->createDocBlock()->addSimpleAnnotation('xml:XmlObject');
        $classCode = <<<'CLASS_END'
/**
 * @xml:XmlObject
 */
class Bla {
}
CLASS_END;
        $this->assertEquals($classCode, $gClass->php());
    }