$this->userRepository = $userRepository; } public function create(UserCreateRequest $request) { $userId = new UserId(uniqid()); $createdUser = new User($userId, $request->getName()); $this->userRepository->save($createdUser); return new UserCreateResponse($userId->getValue()); } }
@return void */ public function testValidCreate() { $repository = new InMemoryUserRepository(); $interactor = new UserService($repository); $request = new UserCreateRequest('test-name'); $response = $interactor->create($request); $this->assertNotNull($response); $this->assertNotNull($response->getCreatedUserId()); $userId = new UserId($response->getCreatedUserId()); $saved = $repository->find($userId); $this->assertEquals($saved->getName(), 'test-name'); } /** * テスト:重複エラー * * @return void */ public function testErrorXxx(){ IN を表現 OUT を表現
@return void */ public function testValidCreate() { $repository = new InMemoryUserRepository(); $interactor = new UserService($repository); $request = new UserCreateRequest('test-name'); $response = $interactor->create($request); $this->assertNotNull($response); $this->assertNotNull($response->getCreatedUserId()); $userId = new UserId($response->getCreatedUserId()); $saved = $repository->find($userId); $this->assertEquals($saved->getName(), 'test-name'); } /** * テスト:重複エラー * * @return void */ public function testErrorXxx(){ IN を表現 OUT を表現 これこそ仕様書