public function testPrependToNotEmptyConstructor()
 {
     // regression, weil das irgendwie nicht ging, hää
     $gClass = new GClass('NoProperties');
     $gClass->createMethod('__construct', array(new GParameter('someP1')));
     $this->extension->setGenerateInConstructor(0)->compile($gClass);
     $constructor = $this->test->gClass($gClass)->hasMethod('__construct', array('oid', 'someP1'))->get();
 }
 protected function createCollectionChecker(GClass $gClass)
 {
     $paramName = $this->relation->getTarget()->getParamName();
     $method = $gClass->createMethod('has' . $this->relation->getTarget()->getMethodName('singular'), array(new GParameter($paramName, $this->relation->getTarget()->getFQN())), \Psc\TPL\TPL::miniTemplate('return $this->%propertyName%->contains($%paramName%);', array('propertyName' => $this->relation->getTarget()->getPropertyName(), 'paramName' => $paramName)));
     if (!$method->hasDocBlock()) {
         $method->createDocBlock();
     }
     $method->getDocBlock()->addSimpleAnnotation('param ' . $this->relation->getTarget()->getFQN() . ' $' . $paramName)->addSimpleAnnotation('return bool');
 }
Esempio n. 3
0
 public function testOwnMethodsGetter()
 {
     $gClass = new GClass($refl = new ReflectionClass('Psc\\Code\\Compile\\Compiler'));
     $this->assertEquals('\\Psc\\Code\\Compile', $gClass->getNamespace());
     $gm = $gClass->getMethod('getClassName');
     // getClassName ist aus Psc\SimpleObject und somit eine Methode einer Vaterklasse
     $m = $refl->getMethod('getClassName');
     $this->assertEquals((string) $m->getDeclaringClass()->getName(), (string) $gm->getDeclaringClass()->getFQN());
     $this->assertArrayHasKey('getClassName', $gClass->getAllMethods());
     $this->assertArrayNotHasKey('getClassName', $gClass->getMethods());
     $this->assertLessThan(count($gClass->getAllMethods()), count($gClass->getMethods()));
     $m = $gClass->createMethod('Test');
     $this->assertNotEmpty($m->getDeclaringClass());
     /* BUG: Namespace verändern verändert die Rückggabe der Methoden */
     $gClass = GClass::factory('Psc\\Code\\Generate\\MyTestClass');
     $this->assertEquals(2, count($gClass->getMethods()));
     $this->assertEquals(2, count($gClass->getAllMethods()));
     $gClass->setNamespace('Psc\\Other\\Than\\Before');
     $this->assertEquals(2, count($gClass->getMethods()));
     $this->assertEquals(2, count($gClass->getAllMethods()));
 }