/** * Send a transactional email * * @param TransactionalEmail $tEmail * * @throws \Exception */ public function send(TransactionalEmail $tEmail) { $this->sendCheckSupportedOptions($tEmail); $this->sendCheckMandatoryOptions($tEmail); $options = $tEmail->getOptions(); $random = $options->getParameterByName('random'); $encrypt = $options->getParameterByName('encrypt'); $content = $options->getParameterByName('content'); if (null !== $content) { $content = $content->getValue(); } $recipientsList = $this->handleRecipients($tEmail->getRecipients(), 1); $this->service->sendObject($tEmail->getTemplateId(), $random->getValue(), $encrypt->getValue(), $recipientsList[0], $this->handleAttributes($tEmail->getAttributes()), $content, self::SYNCHROTYPE_DEFAULT, null, self::UIDKEY_DEFAULT); }
public function testSendObject() { $response = $this->getXMLFileMock('sendObjectResponse.xml'); $uniqueIdentifier = 'uniqueId'; $securityTag = 'securityTag'; $email = '*****@*****.**'; $type = 'INSERT_UPDATE'; $sendDate = time(); $uidKey = 'email'; $parameters['sendrequest'] = ['email' => $email, 'encrypt' => $securityTag, 'random' => $uniqueIdentifier, 'senddate' => $sendDate, 'synchrotype' => $type, 'uidkey' => $uidKey]; $apiClient = $this->getMockBuilder('\\MyLittle\\CampaignCommander\\API\\SOAP\\APIClient')->disableOriginalConstructor()->getMock(); $apiClient->expects($this->once())->method('doCall')->with('sendObject', $parameters)->will($this->returnValue($response)); $this->clientFactory->expects($this->any())->method('createClient')->will($this->returnValue($apiClient)); $service = new NotificationService($this->clientFactory); $this->assertEquals($response, $service->sendObject($uniqueIdentifier, $securityTag, $email, null, null, $type, $sendDate, $uidKey)); }