public function testDelete() { $tagMapper = new TagMapper(); $tagMapper->setId(50); $tagMapper->deleteTag(); $this->assertEquals(new Tag(), $tagMapper->selectTag()); }
/** * * @param Tag $tag_ * @throws InvalidArgumentException */ public function updateTag(Tag $tag_) { try { if (is_null($this->table)) { throw new InvalidArgumentException('Attribute "table" can\'t be NULL !'); } if (isset($this->id) && !is_null($this->id)) { $where = 'id = ' . $this->id; } $tagMapper = new TagMapper(); $tagMapper->setId($this->getFirstId()); $tag = $tagMapper->selectTag(); if (!is_null($tag->getId())) { return parent::update($this->table, $tag_, $where); } elseif (is_null($tag->getId())) { throw new Exception('Tag does not exist !'); } } catch (InvalidArgumentException $e) { print $e->getMessage(); exit; } catch (Exception $e) { print $e->getMessage(); exit; } }
public function goAssociate(stdClass $object_) { try { if (isset($object_) && !emptyObject($object_)) { $announcementMapper = new AnnouncementMapper(); $announcementMapper->setId($object_->id_announcement); $announcement = $announcementMapper->selectAnnouncement(); $tagMapper = new TagMapper(); $tagMapper->setId($object_->id_tag); $tag = $tagMapper->selectTag(); if (!is_null($announcement->getId()) && !is_null($tag->getId())) { if (is_null($user->getId())) { return parent::insert('TO_ASSOCIATE', $object_); } else { throw new Exception('The user is already followed by this user !'); } return parent::insert($this->table, $message_, $arrayFilter); } elseif (is_null($announcement->getId())) { throw new Exception('Announcement is inexistant !'); } elseif (is_null($tag->getId())) { throw new Exception('Tag is inexistant !'); } } elseif (empty($id_announcement_)) { throw new Exception('Id announcement is required !'); } elseif (empty($id_tag_)) { throw new Exception('Id tag is required !'); } } catch (Exception $e) { print $e->getMessage(); exit; } }