public function testNewClass() { $class = new GClass(); $class->setName('tiptoi\\Entities\\Page'); // da dieser Test in keinem NS ist $this->assertEquals('\\tiptoi\\Entities', $class->getNamespace()); $this->assertEquals('Page', $class->getClassName()); $class->addMethod(GMethod::factory('addOID', array(GParameter::factory('$oid', GClass::factory('OID'))), 'if (!$this->oids->contains($oid)) { $this->oids->add($oid); } return $this; ')); $class->setMethod(GMethod::factory('removeOID', array(GParameter::factory('$oid', GClass::factory('OID'))), 'if ($this->oids->contains($oid)) { $this->oids->removeElement($oid); } return $this; ')); $class->addMethod(GMethod::factory('getOIDs', array(), 'return $this->oids;')); $classCode = <<<'CLASS_CODE' class Page { public function addOID(OID $oid) { if (!$this->oids->contains($oid)) { $this->oids->add($oid); } return $this; } public function removeOID(OID $oid) { if ($this->oids->contains($oid)) { $this->oids->removeElement($oid); } return $this; } public function getOIDs() { return $this->oids; } } CLASS_CODE; // file_put_contents('D:\fixture.txt', $classCode); // file_put_contents('D:\compiled.txt',$class->php()); $this->assertEquals($classCode, $class->php()); }