Esempio n. 1
0
 public function create($overwrite = false)
 {
     try {
         $this->class->elevateClass();
         // @todo das mal konfigurieren und fixen
     } catch (\Exception $e) {
         $this->log('Klasse für den Test kann nicht elevated werden: ' . $e->getMessage());
     } catch (\Psc\Code\Generate\ReflectionException $e) {
         $this->log('Klasse für den Test kann nicht elevated werden: ' . $e->getMessage());
     }
     $class = new GClass();
     $class->setName($this->class->getClassName() . 'Test');
     $class->setNamespace($this->class->getNamespace());
     $class->setParentClass($this->testClass);
     $writer = new ClassWriter();
     $writer->setClass($class);
     $class = $this->createStub($class);
     $file = $this->getTestFile();
     if (isset($this->createCallback)) {
         $class = call_user_func($this->createCallback, $class, $this, $writer, $file);
     }
     $writer->addImport($this->class);
     // not really necessary (weil ist ja derselbe NS, aber who knows)
     $file->getDirectory()->create();
     $writer->write($file, array(), $overwrite);
     return $file;
 }
 public function testGetAllMethods()
 {
     $gClass = new GClass(__NAMESPACE__ . '\\ToStubTestClass');
     $gClass->elevateClass();
     $toImplement = array();
     foreach ($gClass->getAllMethods() as $method) {
         if ($method->isAbstract()) {
             $toImplement[] = $method->getName();
         }
     }
     $this->assertArrayEquals(array('implementIt', 'implementItFromParent', 'getName', 'generateDependency'), $toImplement);
 }
Esempio n. 3
0
 public function elevateParent()
 {
     if (isset($this->parentClass)) {
         $this->parentClass->elevateClass();
         foreach ($this->parentClass->getAllProperties() as $gProperty) {
             // nicht addProperty nehmen das würde declaringClass falsch setzen
             $this->properties[$gProperty->getName()] = $gProperty;
         }
         foreach ($this->parentClass->getAllMethods() as $gMethod) {
             // nicht addMethod nehmen das würde declaringClass falsch setzen
             $this->methods[$gMethod->getName()] = $gMethod;
         }
     }
 }
Esempio n. 4
0
 public function testHasInterface()
 {
     $gClass = new GClass('Psc\\Data\\ArrayCollection');
     $gClass->elevateClass();
     //foreach ($gClass->getInterfaces() as $if) {
     //print $if->getFQN()."\n";
     //}
     $this->assertTrue($gClass->hasInterface(new GClass('Doctrine\\Common\\Collections\\Collection')));
 }