public function testGetSetPerson() { $person = new Person(); $person->setAka('Delboy'); $this->user->setPerson($person); $this->assertInstanceOf('Del\\Person\\Entity\\Person', $this->user->getPerson()); $this->assertEquals('Delboy', $this->user->getPerson()->getAka()); }
public function registerUser(array $data) { if (!isset($data['email']) || !isset($data['password']) || !isset($data['confirm'])) { throw new InvalidArgumentException(); } if ($data['password'] !== $data['confirm']) { throw new UserException(UserException::WRONG_PASSWORD); } $criteria = new UserCriteria(); $criteria->setEmail($data['email']); $user = $this->getUserRepository()->findByCriteria($criteria); if (!empty($user)) { throw new UserException(UserException::USER_EXISTS); } $person = new Person(); $user = new User(); $state = new State(State::STATE_UNACTIVATED); $user->setPerson($person)->setEmail($data['email'])->setRegistrationDate(new DateTime())->setState($state); $bcrypt = new Bcrypt(); $bcrypt->setCost(14); $encryptedPassword = $bcrypt->create($data['password']); $user->setPassword($encryptedPassword); $this->saveUser($user); return $user; }