public function testRegister() { $apiUser = $this->createApiUser(); $diamanteUser = $this->createDiamanteUser(); $this->diamanteUserFactory->expects($this->once())->method('create')->with($diamanteUser->getEmail(), $diamanteUser->getFirstName(), $diamanteUser->getLastName())->will($this->returnValue($diamanteUser)); $this->apiUserFactory->expects($this->once())->method('create')->with($apiUser->getEmail(), $apiUser->getPassword())->will($this->returnValue($apiUser)); $this->diamanteUserRepository->expects($this->once())->method('store')->with($diamanteUser); $this->registrationMailer->expects($this->once())->method('sendConfirmationEmail')->with($diamanteUser->getEmail(), $apiUser->getHash()); $command = new RegisterCommand(); $command->email = $diamanteUser->getEmail(); $command->password = $apiUser->getPassword(); $command->firstName = $diamanteUser->getFirstName(); $command->lastName = $diamanteUser->getLastName(); $this->service->register($command); }
public function testProcessWhenDiamanteUserNotExists() { $dummyFrom = $this->getDummyFrom(); $message = new Message(self::DUMMY_UNIQUE_ID, self::DUMMY_MESSAGE_ID, self::DUMMY_SUBJECT, self::DUMMY_CONTENT, $dummyFrom, self::DUMMY_MESSAGE_TO); $assigneeId = 1; $this->diamanteUserRepository->expects($this->once())->method('findUserByEmail')->with($this->equalTo(self::DUMMY_MESSAGE_FROM))->will($this->returnValue(null)); $diamanteUser = new DiamanteUser('test_email', $dummyFrom->getFirstName(), $dummyFrom->getLastName()); $this->diamanteUserFactory->expects($this->once())->method('create')->with($this->equalTo(self::DUMMY_MESSAGE_FROM))->will($this->returnValue($diamanteUser)); $this->diamanteUserRepository->expects($this->once())->method('store')->with($this->equalTo($diamanteUser)); $reporter = new User($diamanteUser->getId(), User::TYPE_DIAMANTE); preg_match('/@(.*)/', self::DUMMY_MESSAGE_FROM, $output); $customerDomain = $output[1]; $this->branchEmailConfigurationService->expects($this->once())->method('getConfigurationBySupportAddressAndCustomerDomain')->with($this->equalTo(self::DUMMY_MESSAGE_TO), $this->equalTo($customerDomain))->will($this->returnValue(null)); $this->emailProcessingSettings->expects($this->once())->method('getDefaultBranchId')->will($this->returnValue(self::DEFAULT_BRANCH_ID)); $this->messageReferenceService->expects($this->once())->method('createTicket')->with($this->equalTo($message->getMessageId()), self::DEFAULT_BRANCH_ID, $message->getSubject(), $message->getContent(), $reporter, $assigneeId); $this->branchEmailConfigurationService->expects($this->once())->method('getBranchDefaultAssignee')->with($this->equalTo(1))->will($this->returnValue(1)); $this->ticketStrategy->process($message); }