/** * @test */ public function thatApiUserRetrievesByUsername() { $email = '*****@*****.**'; $apiUser = $this->getApiUser(); $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->unitOfWork)); $this->unitOfWork->expects($this->once())->method('getEntityPersister')->with($this->equalTo(self::DUMMY_CLASS_NAME))->will($this->returnValue($this->entityPersister)); $this->entityPersister->expects($this->once())->method('load')->with($this->equalTo(array('email' => $email)), $this->equalTo(null), $this->equalTo(null), array(), $this->equalTo(0), $this->equalTo(1), $this->equalTo(null))->will($this->returnValue($apiUser)); $retrievedApiUser = $this->repository->findOneBy(array('email' => $email)); $this->assertNotNull($retrievedApiUser); $this->assertEquals($apiUser, $retrievedApiUser); }
/** * Send user confirmation email * @param SendConfirmCommand $command * @return void */ public function send(SendConfirmCommand $command) { $apiUser = $this->apiUserRepository->findUserByEmail($command->email); if (!$apiUser) { throw new EntityNotFoundException(); } if ($apiUser->isActive()) { throw new \RuntimeException('User is already activated'); } $apiUser->generateHash(); $this->apiUserRepository->store($apiUser); $this->registrationMailer->sendConfirmationEmail($command->email, $apiUser->getHash()); }