- Refactors mailer classes and tests
- Updates Newsletter router to send to multiple recipients
This commit is contained in:
@ -20,11 +20,9 @@ class AmazonSES {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send($newsletter, $subscriber) {
|
function send($newsletter, $subscriber) {
|
||||||
$this->newsletter = $newsletter;
|
|
||||||
$this->subscriber = $subscriber;
|
|
||||||
$result = wp_remote_post(
|
$result = wp_remote_post(
|
||||||
$this->url,
|
$this->url,
|
||||||
$this->request()
|
$this->request($newsletter, $subscriber)
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
!is_wp_error($result) === true &&
|
!is_wp_error($result) === true &&
|
||||||
@ -32,37 +30,38 @@ class AmazonSES {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBody() {
|
function getBody($newsletter, $subscriber) {
|
||||||
return array(
|
return array(
|
||||||
'Action' => 'SendEmail',
|
'Action' => 'SendEmail',
|
||||||
'Version' => '2010-12-01',
|
'Version' => '2010-12-01',
|
||||||
'Source' => $this->from,
|
'Source' => $this->from,
|
||||||
'Destination.ToAddresses.member.1' => $this->subscriber,
|
'Destination.ToAddresses.member.1' => $subscriber,
|
||||||
'Message.Subject.Data' => $this->newsletter['subject'],
|
'Message.Subject.Data' => $newsletter['subject'],
|
||||||
'Message.Body.Html.Data' => $this->newsletter['body']['html'],
|
'Message.Body.Html.Data' => $newsletter['body']['html'],
|
||||||
'Message.Body.Text.Data' => $this->newsletter['body']['text'],
|
'Message.Body.Text.Data' => $newsletter['body']['text'],
|
||||||
'ReturnPath' => $this->from
|
'ReturnPath' => $this->from
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function request() {
|
function request($newsletter, $subscriber) {
|
||||||
|
$body = $this->getBody($newsletter, $subscriber);
|
||||||
return array(
|
return array(
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
'httpversion' => '1.1',
|
'httpversion' => '1.1',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'headers' => array(
|
'headers' => array(
|
||||||
'Host' => $this->awsEndpoint,
|
'Host' => $this->awsEndpoint,
|
||||||
'Authorization' => $this->signRequest($this->getBody()),
|
'Authorization' => $this->signRequest($body),
|
||||||
'X-Amz-Date' => $this->date
|
'X-Amz-Date' => $this->date
|
||||||
),
|
),
|
||||||
'body' => urldecode(http_build_query($this->getBody()))
|
'body' => urldecode(http_build_query($body))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function signRequest() {
|
function signRequest($body) {
|
||||||
$stringToSign = $this->createStringToSign(
|
$stringToSign = $this->createStringToSign(
|
||||||
$this->getCredentialScope(),
|
$this->getCredentialScope(),
|
||||||
$this->getCanonicalRequest()
|
$this->getCanonicalRequest($body)
|
||||||
);
|
);
|
||||||
$signature = hash_hmac($this->hashAlgorithm, $stringToSign, $this->getSigningKey());
|
$signature = hash_hmac($this->hashAlgorithm, $stringToSign, $this->getSigningKey());
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ class AmazonSES {
|
|||||||
return sprintf('%s/%s/%s/%s', $this->dateWithoutTime, $this->awsRegion, $this->awsService, $this->awsTerminationString);
|
return sprintf('%s/%s/%s/%s', $this->dateWithoutTime, $this->awsRegion, $this->awsService, $this->awsTerminationString);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCanonicalRequest() {
|
function getCanonicalRequest($body) {
|
||||||
return implode("\n", array(
|
return implode("\n", array(
|
||||||
'POST',
|
'POST',
|
||||||
'/',
|
'/',
|
||||||
@ -87,7 +86,7 @@ class AmazonSES {
|
|||||||
'x-amz-date:' . $this->date,
|
'x-amz-date:' . $this->date,
|
||||||
'',
|
'',
|
||||||
'host;x-amz-date',
|
'host;x-amz-date',
|
||||||
hash($this->hashAlgorithm, urldecode(http_build_query($this->getBody())))
|
hash($this->hashAlgorithm, urldecode(http_build_query($body)))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,35 +12,34 @@ class ElasticEmail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send($newsletter, $subscriber) {
|
function send($newsletter, $subscriber) {
|
||||||
$this->newsletter = $newsletter;
|
|
||||||
$this->subscriber = $subscriber;
|
|
||||||
$result = wp_remote_post(
|
$result = wp_remote_post(
|
||||||
$this->url,
|
$this->url,
|
||||||
$this->request());
|
$this->request($newsletter, $subscriber));
|
||||||
return (
|
return (
|
||||||
!is_wp_error($result) === true &&
|
!is_wp_error($result) === true &&
|
||||||
!preg_match('/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/', $result['body']) === false
|
!preg_match('/\w{8}-\w{4}-\w{4}-\w{4}-\w{12}/', $result['body']) === false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBody() {
|
function getBody($newsletter, $subscriber) {
|
||||||
return array(
|
return array(
|
||||||
'api_key' => $this->apiKey,
|
'api_key' => $this->apiKey,
|
||||||
'from' => $this->fromEmail,
|
'from' => $this->fromEmail,
|
||||||
'from_name' => $this->fromName,
|
'from_name' => $this->fromName,
|
||||||
'to' => $this->subscriber,
|
'to' => $subscriber,
|
||||||
'subject' => $this->newsletter['subject'],
|
'subject' => $newsletter['subject'],
|
||||||
'body_html' => $this->newsletter['body']['html'],
|
'body_html' => $newsletter['body']['html'],
|
||||||
'body_text' => $this->newsletter['body']['text']
|
'body_text' => $newsletter['body']['text']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function request() {
|
function request($newsletter, $subscriber) {
|
||||||
|
$body = $this->getBody($newsletter, $subscriber);
|
||||||
return array(
|
return array(
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
'httpversion' => '1.0',
|
'httpversion' => '1.0',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'body' => urldecode(http_build_query($this->getBody()))
|
'body' => urldecode(http_build_query($body))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,11 +11,9 @@ class MailGun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send($newsletter, $subscriber) {
|
function send($newsletter, $subscriber) {
|
||||||
$this->newsletter = $newsletter;
|
|
||||||
$this->subscriber = $subscriber;
|
|
||||||
$result = wp_remote_post(
|
$result = wp_remote_post(
|
||||||
$this->url,
|
$this->url,
|
||||||
$this->request()
|
$this->request($newsletter, $subscriber)
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
!is_wp_error($result) === true &&
|
!is_wp_error($result) === true &&
|
||||||
@ -23,13 +21,13 @@ class MailGun {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBody() {
|
function getBody($newsletter, $subscriber) {
|
||||||
return array(
|
return array(
|
||||||
'from' => $this->from,
|
'from' => $this->from,
|
||||||
'to' => $this->subscriber,
|
'to' => $subscriber,
|
||||||
'subject' => $this->newsletter['subject'],
|
'subject' => $newsletter['subject'],
|
||||||
'html' => $this->newsletter['body']['html'],
|
'html' => $newsletter['body']['html'],
|
||||||
'text' => $this->newsletter['body']['text']
|
'text' => $newsletter['body']['text']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +35,8 @@ class MailGun {
|
|||||||
return 'Basic ' . base64_encode('api:' . $this->apiKey);
|
return 'Basic ' . base64_encode('api:' . $this->apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
function request() {
|
function request($newsletter, $subscriber) {
|
||||||
|
$body = $this->getBody($newsletter, $subscriber);
|
||||||
return array(
|
return array(
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
'httpversion' => '1.0',
|
'httpversion' => '1.0',
|
||||||
@ -46,7 +45,7 @@ class MailGun {
|
|||||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
||||||
'Authorization' => $this->auth()
|
'Authorization' => $this->auth()
|
||||||
),
|
),
|
||||||
'body' => urldecode(http_build_query($this->getBody()))
|
'body' => urldecode(http_build_query($body))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,11 +12,9 @@ class MailPoet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send($newsletter, $subscriber) {
|
function send($newsletter, $subscriber) {
|
||||||
$this->newsletter = $newsletter;
|
|
||||||
$this->subscriber = $this->processSubscriber($subscriber);
|
|
||||||
$result = wp_remote_post(
|
$result = wp_remote_post(
|
||||||
$this->url,
|
$this->url,
|
||||||
$this->request()
|
$this->request($newsletter, $this->processSubscriber($subscriber))
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
!is_wp_error($result) === true &&
|
!is_wp_error($result) === true &&
|
||||||
@ -37,19 +35,19 @@ class MailPoet {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBody() {
|
function getBody($newsletter, $subscriber) {
|
||||||
return array(
|
return array(
|
||||||
'to' => (array(
|
'to' => (array(
|
||||||
'address' => $this->subscriber['email'],
|
'address' => $subscriber['email'],
|
||||||
'name' => $this->subscriber['name']
|
'name' => $subscriber['name']
|
||||||
)),
|
)),
|
||||||
'from' => (array(
|
'from' => (array(
|
||||||
'address' => $this->fromEmail,
|
'address' => $this->fromEmail,
|
||||||
'name' => $this->fromName
|
'name' => $this->fromName
|
||||||
)),
|
)),
|
||||||
'subject' => $this->newsletter['subject'],
|
'subject' => $newsletter['subject'],
|
||||||
'html' => $this->newsletter['body']['html'],
|
'html' => $newsletter['body']['html'],
|
||||||
'text' => $this->newsletter['body']['text']
|
'text' => $newsletter['body']['text']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +55,9 @@ class MailPoet {
|
|||||||
return 'Basic ' . base64_encode('api:' . $this->apiKey);
|
return 'Basic ' . base64_encode('api:' . $this->apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
function request() {
|
function request($newsletter, $subscriber) {
|
||||||
$request = array(
|
$body = array($this->getBody($newsletter, $subscriber));
|
||||||
|
return array(
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
'httpversion' => '1.0',
|
'httpversion' => '1.0',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
@ -66,8 +65,7 @@ class MailPoet {
|
|||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Authorization' => $this->auth()
|
'Authorization' => $this->auth()
|
||||||
),
|
),
|
||||||
'body' => json_encode(array($this->getBody()))
|
'body' => json_encode($body)
|
||||||
);
|
);
|
||||||
return $request;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,13 +10,11 @@ class Mandrill {
|
|||||||
$this->fromName = $fromName;
|
$this->fromName = $fromName;
|
||||||
$this->fromEmail = $fromEmail;
|
$this->fromEmail = $fromEmail;
|
||||||
}
|
}
|
||||||
|
|
||||||
function send($newsletter, $subscriber) {
|
function send($newsletter, $subscriber) {
|
||||||
$this->newsletter = $newsletter;
|
|
||||||
$this->subscriber = $this->processSubscriber($subscriber);
|
|
||||||
$result = wp_remote_post(
|
$result = wp_remote_post(
|
||||||
$this->url,
|
$this->url,
|
||||||
$this->request()
|
$this->request($newsletter, $this->processSubscriber($subscriber))
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
!is_wp_error($result) === true &&
|
!is_wp_error($result) === true &&
|
||||||
@ -24,7 +22,7 @@ class Mandrill {
|
|||||||
wp_remote_retrieve_response_code($result) === 200
|
wp_remote_retrieve_response_code($result) === 200
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processSubscriber($subscriber) {
|
function processSubscriber($subscriber) {
|
||||||
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriberData);
|
preg_match('!(?P<name>.*?)\s<(?P<email>.*?)>!', $subscriber, $subscriberData);
|
||||||
if(!isset($subscriberData['email'])) {
|
if(!isset($subscriberData['email'])) {
|
||||||
@ -33,27 +31,28 @@ class Mandrill {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return array(
|
return array(
|
||||||
'email' => $subscriberData['email'],
|
'email' => $subscriberData['email'],
|
||||||
'name' => (isset($subscriberData['name'])) ? $subscriberData['name'] : ''
|
'name' => (isset($subscriberData['name'])) ? $subscriberData['name'] : ''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBody() {
|
function getBody($newsletter, $subscriber) {
|
||||||
return array(
|
return array(
|
||||||
'key' => $this->apiKey,
|
'key' => $this->apiKey,
|
||||||
'message' => array(
|
'message' => array(
|
||||||
'from_email' => $this->fromEmail,
|
'from_email' => $this->fromEmail,
|
||||||
'from_name' => $this->fromName,
|
'from_name' => $this->fromName,
|
||||||
'to' => array($this->subscriber),
|
'to' => array($subscriber),
|
||||||
'subject' => $this->newsletter['subject'],
|
'subject' => $newsletter['subject'],
|
||||||
'html' => $this->newsletter['body']['html'],
|
'html' => $newsletter['body']['html'],
|
||||||
'text' => $this->newsletter['body']['text']
|
'text' => $newsletter['body']['text']
|
||||||
),
|
),
|
||||||
'async' => false,
|
'async' => false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function request() {
|
function request($newsletter, $subscriber) {
|
||||||
|
$body = $this->getBody($newsletter, $subscriber);
|
||||||
return array(
|
return array(
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
'httpversion' => '1.0',
|
'httpversion' => '1.0',
|
||||||
@ -61,7 +60,7 @@ class Mandrill {
|
|||||||
'headers' => array(
|
'headers' => array(
|
||||||
'Content-Type' => 'application/json'
|
'Content-Type' => 'application/json'
|
||||||
),
|
),
|
||||||
'body' => json_encode($this->getBody())
|
'body' => json_encode($body)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,11 +12,9 @@ class SendGrid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function send($newsletter, $subscriber) {
|
function send($newsletter, $subscriber) {
|
||||||
$this->newsletter = $newsletter;
|
|
||||||
$this->subscriber = $subscriber;
|
|
||||||
$result = wp_remote_post(
|
$result = wp_remote_post(
|
||||||
$this->url,
|
$this->url,
|
||||||
$this->request()
|
$this->request($newsletter, $subscriber)
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
!is_wp_error($result) === true &&
|
!is_wp_error($result) === true &&
|
||||||
@ -26,14 +24,14 @@ class SendGrid {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBody() {
|
function getBody($newsletter, $subscriber) {
|
||||||
return array(
|
return array(
|
||||||
'to' => $this->subscriber,
|
'to' => $subscriber,
|
||||||
'from' => $this->fromEmail,
|
'from' => $this->fromEmail,
|
||||||
'fromname' => $this->fromName,
|
'fromname' => $this->fromName,
|
||||||
'subject' => $this->newsletter['subject'],
|
'subject' => $newsletter['subject'],
|
||||||
'html' => $this->newsletter['body']['html'],
|
'html' => $newsletter['body']['html'],
|
||||||
'text' => $this->newsletter['body']['text']
|
'text' => $newsletter['body']['text']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +39,8 @@ class SendGrid {
|
|||||||
return 'Bearer ' . $this->apiKey;
|
return 'Bearer ' . $this->apiKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
function request() {
|
function request($newsletter, $subscriber) {
|
||||||
|
$body = $this->getBody($newsletter, $subscriber);
|
||||||
return array(
|
return array(
|
||||||
'timeout' => 10,
|
'timeout' => 10,
|
||||||
'httpversion' => '1.1',
|
'httpversion' => '1.1',
|
||||||
@ -49,7 +48,7 @@ class SendGrid {
|
|||||||
'headers' => array(
|
'headers' => array(
|
||||||
'Authorization' => $this->auth()
|
'Authorization' => $this->auth()
|
||||||
),
|
),
|
||||||
'body' => urldecode(http_build_query($this->getBody()))
|
'body' => urldecode(http_build_query($body))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,9 +17,8 @@ class AmazonSESCest {
|
|||||||
$this->settings['access_key'],
|
$this->settings['access_key'],
|
||||||
$this->settings['secret_key'],
|
$this->settings['secret_key'],
|
||||||
$this->from);
|
$this->from);
|
||||||
$this->mailer->subscriber =
|
$this->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->newsletter = array(
|
||||||
$this->mailer->newsletter = array(
|
|
||||||
'subject' => 'testing AmazonSES',
|
'subject' => 'testing AmazonSES',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'html' => 'HTML body',
|
'html' => 'HTML body',
|
||||||
@ -36,41 +35,40 @@ class AmazonSESCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanGenerateBody() {
|
function itCanGenerateBody() {
|
||||||
$body = $this->mailer->getBody();
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
expect($body['Action'])->equals('SendEmail');
|
expect($body['Action'])->equals('SendEmail');
|
||||||
expect($body['Version'])->equals('2010-12-01');
|
expect($body['Version'])->equals('2010-12-01');
|
||||||
expect($body['Source'])->equals($this->from);
|
expect($body['Source'])->equals($this->from);
|
||||||
expect($body['Destination.ToAddresses.member.1'])
|
expect($body['Destination.ToAddresses.member.1'])
|
||||||
->contains($this->mailer->subscriber);
|
->contains($this->subscriber);
|
||||||
expect($body['Message.Subject.Data'])
|
expect($body['Message.Subject.Data'])
|
||||||
->equals($this->mailer->newsletter['subject']);
|
->equals($this->newsletter['subject']);
|
||||||
expect($body['Message.Body.Html.Data'])
|
expect($body['Message.Body.Html.Data'])
|
||||||
->equals($this->mailer->newsletter['body']['html']);
|
->equals($this->newsletter['body']['html']);
|
||||||
expect($body['Message.Body.Text.Data'])
|
expect($body['Message.Body.Text.Data'])
|
||||||
->equals($this->mailer->newsletter['body']['text']);
|
->equals($this->newsletter['body']['text']);
|
||||||
expect($body['ReturnPath'])->equals($this->from);
|
expect($body['ReturnPath'])->equals($this->from);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateRequest() {
|
function itCanCreateRequest() {
|
||||||
$request = $this->mailer->request();
|
$request = $this->mailer->request($this->newsletter, $this->subscriber);
|
||||||
expect($request['timeout'])
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
->equals(10);
|
expect($request['timeout'])->equals(10);
|
||||||
expect($request['httpversion'])
|
expect($request['httpversion'])->equals('1.1');
|
||||||
->equals('1.1');
|
expect($request['method'])->equals('POST');
|
||||||
expect($request['method'])
|
expect($request['headers']['Host'])->equals($this->mailer->awsEndpoint);
|
||||||
->equals('POST');
|
|
||||||
expect($request['headers']['Host'])
|
|
||||||
->equals($this->mailer->awsEndpoint);
|
|
||||||
expect($request['headers']['Authorization'])
|
expect($request['headers']['Authorization'])
|
||||||
->equals($this->mailer->signRequest($this->mailer->getBody()));
|
->equals($this->mailer->signRequest($body));
|
||||||
expect($request['headers']['X-Amz-Date'])
|
expect($request['headers']['X-Amz-Date'])->equals($this->mailer->date);
|
||||||
->equals($this->mailer->date);
|
expect($request['body'])->equals(urldecode(http_build_query($body)));
|
||||||
expect($request['body'])
|
|
||||||
->equals(urldecode(http_build_query($this->mailer->getBody())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateCanonicalRequest() {
|
function itCanCreateCanonicalRequest() {
|
||||||
$canonicalRequest = explode("\n", $this->mailer->getCanonicalRequest());
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
|
$canonicalRequest = explode(
|
||||||
|
"\n",
|
||||||
|
$this->mailer->getCanonicalRequest($body)
|
||||||
|
);
|
||||||
expect($canonicalRequest)
|
expect($canonicalRequest)
|
||||||
->equals(
|
->equals(
|
||||||
array(
|
array(
|
||||||
@ -82,7 +80,7 @@ class AmazonSESCest {
|
|||||||
'',
|
'',
|
||||||
'host;x-amz-date',
|
'host;x-amz-date',
|
||||||
hash($this->mailer->hashAlgorithm,
|
hash($this->mailer->hashAlgorithm,
|
||||||
urldecode(http_build_query($this->mailer->getBody()))
|
urldecode(http_build_query($body))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -100,8 +98,9 @@ class AmazonSESCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateStringToSign() {
|
function itCanCreateStringToSign() {
|
||||||
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
$credentialScope = $this->mailer->getCredentialScope();
|
$credentialScope = $this->mailer->getCredentialScope();
|
||||||
$canonicalRequest = $this->mailer->getCanonicalRequest();
|
$canonicalRequest = $this->mailer->getCanonicalRequest($body);
|
||||||
$stringToSing = $this->mailer->createStringToSign(
|
$stringToSing = $this->mailer->createStringToSign(
|
||||||
$credentialScope,
|
$credentialScope,
|
||||||
$canonicalRequest
|
$canonicalRequest
|
||||||
@ -119,7 +118,8 @@ class AmazonSESCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanSignRequest() {
|
function itCanSignRequest() {
|
||||||
$signedRequest = $this->mailer->signRequest();
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
|
$signedRequest = $this->mailer->signRequest($body);
|
||||||
expect($signedRequest)
|
expect($signedRequest)
|
||||||
->contains(
|
->contains(
|
||||||
$this->mailer->awsSigningAlgorithm . ' Credential=' .
|
$this->mailer->awsSigningAlgorithm . ' Credential=' .
|
||||||
@ -127,22 +127,23 @@ class AmazonSESCest {
|
|||||||
$this->mailer->getCredentialScope() . ', ' .
|
$this->mailer->getCredentialScope() . ', ' .
|
||||||
'SignedHeaders=host;x-amz-date, Signature='
|
'SignedHeaders=host;x-amz-date, Signature='
|
||||||
);
|
);
|
||||||
expect(preg_match('!Signature=[A-Fa-f0-9]{64}$!', $signedRequest))->equals(1);
|
expect(preg_match('!Signature=[A-Fa-f0-9]{64}$!', $signedRequest))
|
||||||
|
->equals(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCannotSendWithoutProperAccessKey() {
|
function itCannotSendWithoutProperAccessKey() {
|
||||||
$this->mailer->awsAccessKey = 'somekey';
|
$this->mailer->awsAccessKey = 'somekey';
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->false();
|
expect($result)->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanSend() {
|
function itCanSend() {
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->true();
|
expect($result)->true();
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,8 @@ class ElasticEmailCest {
|
|||||||
$this->fromEmail,
|
$this->fromEmail,
|
||||||
$this->fromName
|
$this->fromName
|
||||||
);
|
);
|
||||||
$this->mailer->subscriber =
|
$this->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->newsletter = array(
|
||||||
$this->mailer->newsletter = array(
|
|
||||||
'subject' => 'testing ElasticEmail',
|
'subject' => 'testing ElasticEmail',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'html' => 'HTML body',
|
'html' => 'HTML body',
|
||||||
@ -28,48 +27,38 @@ class ElasticEmailCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanGenerateBody() {
|
function itCanGenerateBody() {
|
||||||
$body = $this->mailer->getBody();
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
expect($body['api_key'])
|
expect($body['api_key'])->equals($this->settings['api_key']);
|
||||||
->equals($this->settings['api_key']);
|
expect($body['from'])->equals($this->fromEmail);
|
||||||
expect($body['from'])
|
expect($body['from_name'])->equals($this->fromName);
|
||||||
->equals($this->fromEmail);
|
expect($body['to'])->contains($this->subscriber);
|
||||||
expect($body['from_name'])
|
expect($body['subject'])->equals($this->newsletter['subject']);
|
||||||
->equals($this->fromName);
|
expect($body['body_html'])->equals($this->newsletter['body']['html']);
|
||||||
expect($body['to'])
|
expect($body['body_text'])->equals($this->newsletter['body']['text']);
|
||||||
->contains($this->mailer->subscriber);
|
|
||||||
expect($body['subject'])
|
|
||||||
->equals($this->mailer->newsletter['subject']);
|
|
||||||
expect($body['body_html'])
|
|
||||||
->equals($this->mailer->newsletter['body']['html']);
|
|
||||||
expect($body['body_text'])
|
|
||||||
->equals($this->mailer->newsletter['body']['text']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateRequest() {
|
function itCanCreateRequest() {
|
||||||
$request = $this->mailer->request();
|
$request = $this->mailer->request($this->newsletter, $this->subscriber);
|
||||||
expect($request['timeout'])
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
->equals(10);
|
expect($request['timeout'])->equals(10);
|
||||||
expect($request['httpversion'])
|
expect($request['httpversion'])->equals('1.0');
|
||||||
->equals('1.0');
|
expect($request['method'])->equals('POST');
|
||||||
expect($request['method'])
|
expect($request['body'])->equals(urldecode(http_build_query($body)));
|
||||||
->equals('POST');
|
|
||||||
expect($request['body'])
|
|
||||||
->equals(urldecode(http_build_query($this->mailer->getBody())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCannotSendWithoutProperAPIKey() {
|
function itCannotSendWithoutProperAPIKey() {
|
||||||
$this->mailer->apiKey = 'someapi';
|
$this->mailer->apiKey = 'someapi';
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->false();
|
expect($result)->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanSend() {
|
function itCanSend() {
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->true();
|
expect($result)->true();
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,8 @@ class MailGunCest {
|
|||||||
$this->settings['api_key'],
|
$this->settings['api_key'],
|
||||||
$this->from
|
$this->from
|
||||||
);
|
);
|
||||||
$this->mailer->subscriber =
|
$this->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->newsletter = array(
|
||||||
$this->mailer->newsletter = array(
|
|
||||||
'subject' => 'testing MailGun',
|
'subject' => 'testing MailGun',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'html' => 'HTML body',
|
'html' => 'HTML body',
|
||||||
@ -28,17 +27,12 @@ class MailGunCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanGenerateBody() {
|
function itCanGenerateBody() {
|
||||||
$body = $this->mailer->getBody();
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
expect($body['from'])
|
expect($body['from'])->equals($this->from);
|
||||||
->equals($this->from);
|
expect($body['to'])->equals($this->subscriber);
|
||||||
expect($body['to'])
|
expect($body['subject'])->equals($this->newsletter['subject']);
|
||||||
->equals($this->mailer->subscriber);
|
expect($body['html'])->equals($this->newsletter['body']['html']);
|
||||||
expect($body['subject'])
|
expect($body['text'])->equals($this->newsletter['body']['text']);
|
||||||
->equals($this->mailer->newsletter['subject']);
|
|
||||||
expect($body['html'])
|
|
||||||
->equals($this->mailer->newsletter['body']['html']);
|
|
||||||
expect($body['text'])
|
|
||||||
->equals($this->mailer->newsletter['body']['text']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanDoBasicAuth() {
|
function itCanDoBasicAuth() {
|
||||||
@ -47,26 +41,23 @@ class MailGunCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateRequest() {
|
function itCanCreateRequest() {
|
||||||
$request = $this->mailer->request();
|
$request = $this->mailer->request($this->newsletter, $this->subscriber);
|
||||||
expect($request['timeout'])
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
->equals(10);
|
expect($request['timeout'])->equals(10);
|
||||||
expect($request['httpversion'])
|
expect($request['httpversion'])->equals('1.0');
|
||||||
->equals('1.0');
|
expect($request['method'])->equals('POST');
|
||||||
expect($request['method'])
|
|
||||||
->equals('POST');
|
|
||||||
expect($request['headers']['Content-Type'])
|
expect($request['headers']['Content-Type'])
|
||||||
->equals('application/x-www-form-urlencoded');
|
->equals('application/x-www-form-urlencoded');
|
||||||
expect($request['headers']['Authorization'])
|
expect($request['headers']['Authorization'])
|
||||||
->equals('Basic ' . base64_encode('api:' . $this->settings['api_key']));
|
->equals('Basic ' . base64_encode('api:' . $this->settings['api_key']));
|
||||||
expect($request['body'])
|
expect($request['body'])->equals(urldecode(http_build_query($body)));
|
||||||
->equals(urldecode(http_build_query($this->mailer->getBody())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCannotSendWithoutProperAPIKey() {
|
function itCannotSendWithoutProperAPIKey() {
|
||||||
$this->mailer->apiKey = 'someapi';
|
$this->mailer->apiKey = 'someapi';
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->false();
|
expect($result)->false();
|
||||||
}
|
}
|
||||||
@ -75,16 +66,16 @@ class MailGunCest {
|
|||||||
$this->mailer->url =
|
$this->mailer->url =
|
||||||
str_replace($this->settings['domain'], 'somedomain', $this->mailer->url);
|
str_replace($this->settings['domain'], 'somedomain', $this->mailer->url);
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->false();
|
expect($result)->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanSend() {
|
function itCanSend() {
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->true();
|
expect($result)->true();
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ class MailPoetCest {
|
|||||||
$this->fromEmail,
|
$this->fromEmail,
|
||||||
$this->fromName
|
$this->fromName
|
||||||
);
|
);
|
||||||
$this->mailer->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
$this->mailer->newsletter = array(
|
$this->newsletter = array(
|
||||||
'subject' => 'testing MailPoet',
|
'subject' => 'testing MailPoet',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'html' => 'HTML body',
|
'html' => 'HTML body',
|
||||||
@ -27,37 +27,28 @@ class MailPoetCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanGenerateBody() {
|
function itCanGenerateBody() {
|
||||||
$this->mailer->subscriber = $this->mailer->processSubscriber($this->mailer->subscriber);
|
$subscriber = $this->mailer->processSubscriber($this->subscriber);
|
||||||
$body = $this->mailer->getBody();
|
$body = $this->mailer->getBody($this->newsletter, $subscriber);
|
||||||
expect($body['to']['address'])
|
expect($body['to']['address'])->equals($subscriber['email']);
|
||||||
->equals($this->mailer->subscriber['email']);
|
expect($body['to']['name'])->equals($subscriber['name']);
|
||||||
expect($body['to']['name'])
|
expect($body['from']['address'])->equals($this->fromEmail);
|
||||||
->equals($this->mailer->subscriber['name']);
|
expect($body['subject'])->equals($this->newsletter['subject']);
|
||||||
expect($body['from']['address'])
|
expect($body['html'])->equals($this->newsletter['body']['html']);
|
||||||
->equals($this->fromEmail);
|
expect($body['text'])->equals($this->newsletter['body']['text']);
|
||||||
expect($body['subject'])
|
|
||||||
->equals($this->mailer->newsletter['subject']);
|
|
||||||
expect($body['html'])
|
|
||||||
->equals($this->mailer->newsletter['body']['html']);
|
|
||||||
expect($body['text'])
|
|
||||||
->equals($this->mailer->newsletter['body']['text']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateRequest() {
|
function itCanCreateRequest() {
|
||||||
$this->mailer->subscriber = $this->mailer->processSubscriber($this->mailer->subscriber);
|
$subscriber = $this->mailer->processSubscriber(
|
||||||
$request = $this->mailer->request();
|
'Recipient <mailpoet-phoenix-test@mailinator.com>'
|
||||||
expect($request['timeout'])
|
);
|
||||||
->equals(10);
|
$body = array($this->mailer->getBody($this->newsletter, $subscriber));
|
||||||
expect($request['httpversion'])
|
$request = $this->mailer->request($this->newsletter, $subscriber);
|
||||||
->equals('1.0');
|
expect($request['timeout'])->equals(10);
|
||||||
expect($request['method'])
|
expect($request['httpversion'])->equals('1.0');
|
||||||
->equals('POST');
|
expect($request['method'])->equals('POST');
|
||||||
expect($request['headers']['Content-Type'])
|
expect($request['headers']['Content-Type'])->equals('application/json');
|
||||||
->equals('application/json');
|
expect($request['headers']['Authorization'])->equals($this->mailer->auth());
|
||||||
expect($request['headers']['Authorization'])
|
expect($request['body'])->equals(json_encode($body));
|
||||||
->equals($this->mailer->auth());
|
|
||||||
expect($request['body'])
|
|
||||||
->equals(json_encode(array($this->mailer->getBody())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanProcessSubscriber() {
|
function itCanProcessSubscriber() {
|
||||||
@ -89,16 +80,16 @@ class MailPoetCest {
|
|||||||
function itCannotSendWithoutProperAPIKey() {
|
function itCannotSendWithoutProperAPIKey() {
|
||||||
$this->mailer->apiKey = 'someapi';
|
$this->mailer->apiKey = 'someapi';
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->false();
|
expect($result)->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanSend() {
|
function itCanSend() {
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->true();
|
expect($result)->true();
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,8 @@ class MandrillCest {
|
|||||||
$this->fromEmail,
|
$this->fromEmail,
|
||||||
$this->fromName
|
$this->fromName
|
||||||
);
|
);
|
||||||
$this->mailer->subscriber =
|
$this->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->newsletter = array(
|
||||||
$this->mailer->newsletter = array(
|
|
||||||
'subject' => 'testing Mandrill',
|
'subject' => 'testing Mandrill',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'html' => 'HTML body',
|
'html' => 'HTML body',
|
||||||
@ -28,41 +27,27 @@ class MandrillCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanGenerateBody() {
|
function itCanGenerateBody() {
|
||||||
$body = $this->mailer->getBody();
|
$subscriber = $this->mailer->processSubscriber($this->subscriber);
|
||||||
|
$body = $this->mailer->getBody($this->newsletter, $subscriber);
|
||||||
expect($body['key'])->equals($this->settings['api_key']);
|
expect($body['key'])->equals($this->settings['api_key']);
|
||||||
expect($body['message']['from_email'])->equals(
|
expect($body['message']['from_email'])->equals($this->fromEmail);
|
||||||
$this->fromEmail
|
expect($body['message']['from_name'])->equals($this->fromName);
|
||||||
);
|
expect($body['message']['to'])->equals(array($subscriber));
|
||||||
expect($body['message']['from_name'])->equals(
|
expect($body['message']['subject'])->equals($this->newsletter['subject']);
|
||||||
$this->fromName
|
expect($body['message']['html'])->equals($this->newsletter['body']['html']);
|
||||||
);
|
expect($body['message']['text'])->equals($this->newsletter['body']['text']);
|
||||||
expect($body['message']['to'])->equals(
|
|
||||||
array($this->mailer->subscriber)
|
|
||||||
);
|
|
||||||
expect($body['message']['subject'])->equals(
|
|
||||||
$this->mailer->newsletter['subject']
|
|
||||||
);
|
|
||||||
expect($body['message']['html'])->equals(
|
|
||||||
$this->mailer->newsletter['body']['html']
|
|
||||||
);
|
|
||||||
expect($body['message']['text'])->equals(
|
|
||||||
$this->mailer->newsletter['body']['text']
|
|
||||||
);
|
|
||||||
expect($body['async'])->false();
|
expect($body['async'])->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateRequest() {
|
function itCanCreateRequest() {
|
||||||
$request = $this->mailer->request();
|
$subscriber = $this->mailer->processSubscriber($this->subscriber);
|
||||||
expect($request['timeout'])
|
$body = $this->mailer->getBody($this->newsletter, $subscriber);
|
||||||
->equals(10);
|
$request = $this->mailer->request($this->newsletter, $subscriber);
|
||||||
expect($request['httpversion'])
|
expect($request['timeout'])->equals(10);
|
||||||
->equals('1.0');
|
expect($request['httpversion'])->equals('1.0');
|
||||||
expect($request['method'])
|
expect($request['method'])->equals('POST');
|
||||||
->equals('POST');
|
expect($request['headers']['Content-Type'])->equals('application/json');
|
||||||
expect($request['headers']['Content-Type'])
|
expect($request['body'])->equals(json_encode($body));
|
||||||
->equals('application/json');
|
|
||||||
expect($request['body'])
|
|
||||||
->equals(json_encode($this->mailer->getBody()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanProcessSubscriber() {
|
function itCanProcessSubscriber() {
|
||||||
@ -89,16 +74,16 @@ class MandrillCest {
|
|||||||
function itCannotSendWithoutProperAPIKey() {
|
function itCannotSendWithoutProperAPIKey() {
|
||||||
$this->mailer->apiKey = 'someapi';
|
$this->mailer->apiKey = 'someapi';
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->false();
|
expect($result)->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanSend() {
|
function itCanSend() {
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->true();
|
expect($result)->true();
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,8 @@ class SendGridCest {
|
|||||||
$this->fromEmail,
|
$this->fromEmail,
|
||||||
$this->fromName
|
$this->fromName
|
||||||
);
|
);
|
||||||
$this->mailer->subscriber =
|
$this->subscriber = 'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
||||||
'Recipient <mailpoet-phoenix-test@mailinator.com>';
|
$this->newsletter = array(
|
||||||
$this->mailer->newsletter = array(
|
|
||||||
'subject' => 'testing SendGrid',
|
'subject' => 'testing SendGrid',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'html' => 'HTML body',
|
'html' => 'HTML body',
|
||||||
@ -28,53 +27,44 @@ class SendGridCest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function itCanGenerateBody() {
|
function itCanGenerateBody() {
|
||||||
$body = $this->mailer->getBody();
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
expect($body['to'])
|
expect($body['to'])->contains($this->subscriber);
|
||||||
->contains($this->mailer->subscriber);
|
expect($body['from'])->equals($this->fromEmail);
|
||||||
expect($body['from'])
|
expect($body['fromname'])->equals($this->fromName);
|
||||||
->equals($this->fromEmail);
|
expect($body['subject'])->equals($this->newsletter['subject']);
|
||||||
expect($body['fromname'])
|
expect($body['html'])->equals($this->newsletter['body']['html']);
|
||||||
->equals($this->fromName);
|
expect($body['text'])->equals($this->newsletter['body']['text']);
|
||||||
expect($body['subject'])
|
|
||||||
->equals($this->mailer->newsletter['subject']);
|
|
||||||
expect($body['html'])
|
|
||||||
->equals($this->mailer->newsletter['body']['html']);
|
|
||||||
expect($body['text'])
|
|
||||||
->equals($this->mailer->newsletter['body']['text']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanCreateRequest() {
|
function itCanCreateRequest() {
|
||||||
$request = $this->mailer->request();
|
$body = $this->mailer->getBody($this->newsletter, $this->subscriber);
|
||||||
expect($request['timeout'])
|
$request = $this->mailer->request($this->newsletter, $this->subscriber);
|
||||||
->equals(10);
|
expect($request['timeout'])->equals(10);
|
||||||
expect($request['httpversion'])
|
expect($request['httpversion'])->equals('1.1');
|
||||||
->equals('1.1');
|
expect($request['method'])->equals('POST');
|
||||||
expect($request['method'])
|
|
||||||
->equals('POST');
|
|
||||||
expect($request['headers']['Authorization'])
|
expect($request['headers']['Authorization'])
|
||||||
->equals('Bearer ' . $this->settings['api_key']);
|
->equals('Bearer ' . $this->settings['api_key']);
|
||||||
expect($request['body'])
|
expect($request['body'])->equals(urldecode(http_build_query($body)));
|
||||||
->equals(urldecode(http_build_query($this->mailer->getBody())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanDoBasicAuth() {
|
function itCanDoBasicAuth() {
|
||||||
expect($this->mailer->auth())
|
expect($this->mailer->auth())
|
||||||
->equals('Bearer ' . $this->settings['api_key']);
|
->equals('Bearer ' . $this->settings['api_key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCannotSendWithoutProperAPIKey() {
|
function itCannotSendWithoutProperAPIKey() {
|
||||||
$this->mailer->apiKey = 'someapi';
|
$this->mailer->apiKey = 'someapi';
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->false();
|
expect($result)->false();
|
||||||
}
|
}
|
||||||
|
|
||||||
function itCanSend() {
|
function itCanSend() {
|
||||||
$result = $this->mailer->send(
|
$result = $this->mailer->send(
|
||||||
$this->mailer->newsletter,
|
$this->newsletter,
|
||||||
$this->mailer->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
expect($result)->true();
|
expect($result)->true();
|
||||||
}
|
}
|
||||||
|
@ -37,20 +37,15 @@ class SMTPCest {
|
|||||||
|
|
||||||
function itCanBuildMailer() {
|
function itCanBuildMailer() {
|
||||||
$mailer = $this->mailer->buildMailer();
|
$mailer = $this->mailer->buildMailer();
|
||||||
expect($mailer->getTransport()
|
expect($mailer->getTransport()->getHost())
|
||||||
->getHost())
|
|
||||||
->equals($this->settings['host']);
|
->equals($this->settings['host']);
|
||||||
expect($mailer->getTransport()
|
expect($mailer->getTransport()->getPort())
|
||||||
->getPort())
|
|
||||||
->equals($this->settings['port']);
|
->equals($this->settings['port']);
|
||||||
expect($mailer->getTransport()
|
expect($mailer->getTransport()->getUsername())
|
||||||
->getUsername())
|
|
||||||
->equals($this->settings['authentication']['login']);
|
->equals($this->settings['authentication']['login']);
|
||||||
expect($mailer->getTransport()
|
expect($mailer->getTransport()->getPassword())
|
||||||
->getPassword())
|
|
||||||
->equals($this->settings['authentication']['password']);
|
->equals($this->settings['authentication']['password']);
|
||||||
expect($mailer->getTransport()
|
expect($mailer->getTransport()->getEncryption())
|
||||||
->getEncryption())
|
|
||||||
->equals($this->settings['encryption']);
|
->equals($this->settings['encryption']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,4 +89,4 @@ class SMTPCest {
|
|||||||
);
|
);
|
||||||
expect($result)->true();
|
expect($result)->true();
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user