/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * * @return \Illuminate\Http\Response */ public function store(Request $request) { $data = $request->only(['name', 'email', 'password']); $user = new User(new Email($data['email'])); $user->setName($data['name'])->setPassword($data['password']); $savedUser = $this->userRepository->save($user); return response()->json($savedUser); }
public function testSave() { $user = new User(new Email('*****@*****.**')); $user->setPassword('savedPassword')->setName('Saved John'); try { $toDelete = $this->userRepository->findByEmail($user->getEmail()); $this->userRepository->delete($toDelete); } catch (OutOfBoundsException $e) { } $savedUser = $this->userRepository->save($user); $this->assertNotNull($savedUser->getId()); $toDelete = $this->userRepository->findByEmail($user->getEmail()); $this->userRepository->delete($toDelete); }
/** * @param \TestController\Domain\Entities\User $user * * @return bool */ public function delete(User $user) { return $this->pdo->exec("DELETE FROM users WHERE id=" . $user->getId()) === true; }
public function testDefaultValuesAreNull() { $user = new User($this->getMockEmail()); $this->assertNull($user->getName()); $this->assertNull($user->getPassword()); }