/** * Convert data array into entity * * @return QuickTag\Model\StoredTag * @param array $data * @access public */ public function build($data) { $object = new StoredTag(); if ($data['tag_user_context'] !== null) { $object->setUserContext($data['tag_user_context']); } if ($data['tag_weight'] !== null) { $object->setWeight($data['tag_weight']); } $object->setTagId($data['tag_id']); $object->setTagCreated($data['tag_date_created']); $object->setTitle($data['tag_title']); return $object; }
public function testEntityDemolish() { $tag_id = 1; $tag_user_context = 3; $tag_date_created = new DateTime(); $tag_weight = 3.56; $tag_title = 'finance'; $data = array('tag_id' => $tag_id, 'tag_user_context' => $tag_user_context, 'tag_date_created' => $tag_date_created, 'tag_weight' => $tag_weight, 'tag_title' => $tag_title); $builder = new TagBuilder(); $entity = new StoredTag(); $entity->setTagId($tag_id); $entity->setUserContext($tag_user_context); $entity->setTagCreated($tag_date_created); $entity->setWeight($tag_weight); $entity->setTitle($tag_title); $this->assertEquals($data, $builder->demolish($entity)); }
/** * @expectedException QuickTag\QuickTagException * @expectedExceptionMessage SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'tag_title' cannot be null */ public function testSaveWithError() { $gateway = $this->getTableGateway(); $event = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface'); $mapper = new TagMapper($event, $gateway); $tag = new StoredTag(); $tag->setUserContext(1); $tag->setWeight(1); $result = $mapper->save($tag); }