public function testCreateUserHandlerWillCallStoreOnRepository() { $id = Uuid::createNew(); $userName = '******'; $emailAddress = 'bar'; $fullName = 'baz boo'; $command = new CreateUser($id, $userName, $emailAddress, $fullName); $user = User::create($command->getId(), $command->getUserName(), $command->getEmailAddress(), $command->getFullName()); $repository = $this->getMockBuilder(Repository::class)->disableOriginalConstructor()->getMock(); $repository->expects(self::once())->method('store')->with($user); $handler = new CreateUserHandler($repository); $handler->handle($command); }
/** * @param CreateUser $command */ public function handleCreateUser(CreateUser $command) { $user = User::create($command->getId(), $command->getUserName(), $command->getEmailAddress(), $command->getFullName()); $this->repository->store($user); }