Esempio n. 1
0
 public function testNewInstanceWithoutConstructor()
 {
     $gClass = new GClass('MyConstructorThrowsExceptionClass');
     $gClass->setNamespace(__NAMESPACE__);
     $instance = $gClass->newInstance(array(), GClass::WITHOUT_CONSTRUCTOR);
     $this->assertInstanceOf($gClass->getFQN(), $instance);
     $this->assertTrue($instance->checkProperty);
 }
 /**
  * Erstellt ein leeres Entity
  *
  * kann abgeleitet werden, falls der constructor von {$this->getEntityName()} Parameter braucht
  */
 public function createEmptyEntity($revision = NULL)
 {
     // @TODO check ob entity einen constructor hat, der parameter braucht?
     $c = $this->getEntityName();
     try {
         $gClass = new GClass($c);
         // wir rufen hier nicht den constructor auf
         return $gClass->newInstance(array(), GClass::WITHOUT_CONSTRUCTOR);
     } catch (\ErrorException $e) {
         if (mb_strpos($e->getMessage(), 'Missing argument') !== FALSE) {
             throw new \Psc\Exception(sprintf("Kann kein leeres Entity '%s' mit leerem Constructor erstellen. createEmptyEntity() kann im Controller abgeleitet werden, um das Problem zu beheben", $c), 0, $e);
         } else {
             throw $e;
         }
     }
 }