public function testCreateProperty() { $builder = new EntityBuilder('Person', $this->module); $this->assertInstanceOf('Psc\\Code\\Generate\\ClassBuilderProperty', $builder->createProperty('email', $this->createType('Email'))); $this->assertTrue($builder->getGClass()->hasProperty('email')); $this->assertTrue($builder->getGClass()->hasMethod('getEmail')); $this->assertTrue($builder->getGClass()->hasMethod('setEmail')); $this->assertEquals($this->createType('Email'), $builder->getProperty('email')->getType()); }
protected function assertCommonRelation(EntityBuilder $builder, $property, $annotationName, $targetEntity) { $this->assertTrue($builder->hasProperty($property), 'Builder hat property: ' . $property . ' nicht.'); $property = $builder->getProperty($property); $this->assertNotNull($property->getDocBlock(), 'DocBlock des Properties: ' . $property->getName() . ' ist nicht gesetzt'); $this->assertInstanceOf('Webforge\\Types\\Type', $type = $property->getType(), 'Type des Properties: ' . $property->getName() . ' ist nicht gesetzt'); if ($type->getName() === 'PersistentCollection') { $innerType = $type->getType(); $this->assertInstanceof('Webforge\\Types\\ObjectType', $innerType); $this->assertEquals($targetEntity, $innerType->getClass()->getFQN()); } elseif ($type->getName() === 'Entity') { $this->assertEquals($targetEntity, $type->getClass()->getFQN()); } else { $this->fail('Type (' . $type->getName() . ') ist weder Collection noch Object für Property: ' . $property->getName()); } $relationAnnotation = $this->assertHasDCAnnotation($property->getDocBlock(), $annotationName); $this->assertEquals($targetEntity, $relationAnnotation->targetEntity, 'Target Entity stimmt nicht überein'); return $relationAnnotation; }