public function testWrite()
 {
     $code = new PhpClass();
     $code->setName('FirstClass')->setNamespace(new NamespaceClass('ClassGenerator'))->setDescription('Class description')->setExtends('\\ArrayIterator')->addMethod(new Method())->addProperty(new Property());
     $path = $this->path;
     if (!is_dir($path)) {
         $path = './data';
         $i = 0;
         while ($i < 3 and !realpath($path)) {
             $path = '../' . $path;
             $i++;
         }
     }
     if (!is_dir($path)) {
         mkdir($path, 0777, true);
     }
     $writer = new Writer(array('phpClass' => $code, 'path' => $path));
     $writer->write();
     $this->assertFileExists($path . '/' . $code->getNamespace()->getPath() . '/' . $code->getName() . '.php');
 }
 public function testEvaluateClassUsingTrait()
 {
     $this->isTraitAvailable();
     $code = new PhpClass();
     $code->setName('TestTrait')->setDescription('Class description')->setExtends('\\ArrayIterator')->addMethod(new Method())->addProperty(new Property())->addComposition('\\ClassGeneration\\Test\\Provider\\OtherTrait')->addComposition('\\ClassGeneration\\Test\\Provider\\ObjectTrait');
     $code->evaluate();
     $this->assertTrue(class_exists('\\TestTrait'));
     $reflection = new \ReflectionClass($code->getFullName());
     $this->assertInstanceOf('\\ReflectionMethod', $reflection->getMethod('doSomething'));
 }