public function testCreate() { $entity = new Entity($this->entityManager, TestEntity::class); $entity->setTable('test'); $entity->addField('key', new Field(new PropertySetter($entity, 'field'), new PropertyGetter($entity, 'field'))); $entity->setPrimaryKey('key'); $object = $entity->create(['key' => 'value']); $this->assertInstanceOf(TestEntity::class, $object); $this->assertEquals('value', $object->field); }
/** * @param Entity $entity */ private function readTableName(Entity $entity) { $className = $entity->getClassName(); try { $classAnnotations = $this->annotationReader->readClass($className); $entity->setTable($classAnnotations->get('Table')); } catch (\OutOfBoundsException $e) { throw new EntityDefinitionException("Missing Table annotation of {$className}", 0, $e); } }