protected function setUp() { \Bh\Lib\Mapper::getEntityManager()->clear(); $this->getConnection(); $this->setForeignKeyChecks(false); parent::setUp(); $this->setForeignKeyChecks(true); }
protected function editEntry($class, $newEntry) { $result = null; if ($newEntry->getUser() === $this->getCurrentUser() && ($newEntry->getId() && $this->{"get{$class}"}($newEntry->getId()) || is_null($newEntry->getId()))) { $newEntry->setActivity($this->addActivity($newEntry->getActivity())); $newEntry->setCategory($this->addCategory($newEntry->getCategory())); $newEntry->setTags($this->addTags($newEntry->getTags())); if (is_null($newEntry->getId())) { Mapper::save($newEntry); } Mapper::commit(); $result = $newEntry; } return $result; }
public function editUser(User $newUser) { $result = false; $newId = $newUser->getId(); $newNameUser = $this->getUserByName($newUser->getName()); $newEmailUser = $this->getUserByEmail($newUser->getEmail()); $currentUser = $this->getCurrentUser(); if (is_null($newId) && !$newNameUser && !$newEmailUser) { Mapper::save($newUser); Mapper::commit(); $result = true; } elseif ($currentUser && $currentUser->getId() === $newId && (!$newNameUser || $newNameUser === $currentUser) && (!$newEmailUser || $newEmailUser === $currentUser)) { if (!$newUser->getPass()) { $newUser->copyPass($currentUser->getPass()); } $currentUser = $newUser; Mapper::save($newUser); Mapper::commit(); $result = true; } return $result; }