summaryrefslogtreecommitdiffstats
path: root/test/unit/SendGridCompatibiility
diff options
context:
space:
mode:
authornornholdj <nornholdj@gmail.com>2014-11-12 13:40:03 -0500
committernornholdj <nornholdj@gmail.com>2014-11-12 13:40:03 -0500
commitfa4f9b2fabb847f99ac52f6cfc869f4d4b629104 (patch)
tree9780e7f6cf9ae6112a26f8a6acdf2cf839fcb8c0 /test/unit/SendGridCompatibiility
parenta91660135323f01376bb860a5ad9abaedebf9f4f (diff)
downloadphp-sparkpost-fa4f9b2fabb847f99ac52f6cfc869f4d4b629104.zip
php-sparkpost-fa4f9b2fabb847f99ac52f6cfc869f4d4b629104.tar.gz
php-sparkpost-fa4f9b2fabb847f99ac52f6cfc869f4d4b629104.tar.bz2
MA-1084 #time 3h updated to be usable with php 5.3
Diffstat (limited to 'test/unit/SendGridCompatibiility')
-rw-r--r--test/unit/SendGridCompatibiility/EmailTest.php159
-rw-r--r--test/unit/SendGridCompatibiility/SendGridTest.php3
2 files changed, 162 insertions, 0 deletions
diff --git a/test/unit/SendGridCompatibiility/EmailTest.php b/test/unit/SendGridCompatibiility/EmailTest.php
new file mode 100644
index 0000000..dbabb77
--- /dev/null
+++ b/test/unit/SendGridCompatibiility/EmailTest.php
@@ -0,0 +1,159 @@
+<?php
+use SparkPost\SendGridCompatibility\Email;
+
+class SendGridCompatibilityEmailTest extends \PHPUnit_Framework_TestCase {
+
+ private $email;
+
+ public function setup() {
+ $this->email = new Email();
+ }
+
+ public function testConstruct() {
+ $email = new Email();
+
+ $this->assertInstanceOf('SparkPost\SendGridCompatibility\Email', $email);
+ $this->assertInternalType('array', $email->model);
+ }
+
+ public function testAddTo() {
+ $fakeEmail = 'joe.schmoe@test.com';
+ $this->email->addTo($fakeEmail);
+
+ $this->assertEquals(array(array('address'=>array('email'=>$fakeEmail))), $this->email->model['recipients']);
+ }
+
+ public function testAddToWithName() {
+ $fakeEmail = 'joe.schmoe@test.com';
+ $fakeName = 'Joe Schmoe';
+ $this->email->addTo($fakeEmail, $fakeName);
+
+ $this->assertEquals(array(array('address'=>array('email'=>$fakeEmail, 'name'=>$fakeName))), $this->email->model['recipients']);
+ }
+
+ public function testSetTos() {
+ $tos = array();
+ array_push($tos, array('address'=>array('email'=>'joe.schmoe@test.com', 'name'=>'Joe Schmoe')));
+ array_push($tos, array('address'=>array('email'=>'jill.schmoe@test.com', 'name'=>'Jill Schmoe')));
+ $this->email->setTos($tos);
+
+ $this->assertEquals($tos, $this->email->model['recipients']);
+ }
+
+ public function testSetFrom() {
+ $this->email->setFrom('test@email.com');
+
+ $this->assertEquals(array('email'=>'test@email.com'), $this->email->model['from']);
+ }
+
+
+ public function testSetFromName() {
+ $this->email->setFrom('test@email.com');
+ $this->email->setFromName('Test Bot');
+
+ $this->assertEquals(array('email'=>'test@email.com', 'name'=>'Test Bot'), $this->email->model['from']);
+ }
+
+ /**
+ * @desc Tests that setting the fromName prior to setting the From field throws an exception
+ * @expectedException Exception
+ * @expectedExceptionMessage Must set "From" prior to setting "From Name".
+ */
+ public function testSetFromNameWithoutAddress() {
+ $this->email->setFromName('Test Bot');
+ }
+
+ public function testSetReplyto() {
+ $this->email->setReplyTo('test@email.com');
+
+ $this->assertEquals('test@email.com', $this->email->model['replyTo']);
+ }
+
+
+ public function testAddBcc() {
+ $this->email->addBcc('test@email.com');
+
+ $this->assertEquals(array('test@email.com'), $this->email->model['bcc']);
+ }
+
+ public function testSetSubject() {
+ $this->email->setSubject('Awesome Subject');
+
+ $this->assertEquals('Awesome Subject', $this->email->model['subject']);
+ }
+
+ public function testSetText() {
+ $value = 'This is some plain/text';
+ $this->email->setText($value);
+
+ $this->assertEquals($value, $this->email->model['text']);
+ }
+
+ public function testSetHtml() {
+ $value = '<html><body><p>This is some html</p></body></html>';
+ $this->email->setHtml($value);
+
+ $this->assertEquals($value, $this->email->model['html']);
+ }
+
+ public function testAddCategory() {
+ $value = 'Category A';
+ $this->email->addCategory($value);
+
+ $this->assertEquals(array($value), $this->email->model['tags']);
+ }
+
+ /**
+ * @desc Tests that setting an attachment throws a meaningful exception
+ * @expectedException Exception
+ * @expectedExceptionMessage Adding attachments is not yet supported
+ */
+ public function testAddAttachment() {
+ $this->email->addAttachment('blah');
+ }
+
+ public function testAddSubstitution() {
+ $this->email->addSubstitution('item', 'baseball bat');
+
+ $this->assertEquals(array('item'=>'baseball bat'), $this->email->model['substitutionData']);
+ }
+
+ public function testAddSection() {
+ $this->email->addSection('item', 'baseball bat');
+
+ $this->assertEquals(array('item'=>'baseball bat'), $this->email->model['substitutionData']);
+ }
+
+ /**
+ * @desc Tests that setting an attachment throws a meaningful exception
+ * @expectedException Exception
+ * @expectedExceptionMessage Adding Unique Arguments is not yet supported
+ */
+ public function testAddUniqueArguement() {
+ $this->email->addUniqueArg('blah', 'someblah');
+ }
+
+
+ /**
+ * @desc Tests that setting an unique argument throws a meaningful exception
+ * @expectedException Exception
+ * @expectedExceptionMessage Setting Unique Arguments is not yet supported
+ */
+ public function testSetUniqueArgs() {
+ $this->email->setUniqueArgs(['blah', 'andBlah']);
+ }
+
+
+ public function testAddHeader() {
+ $value = 'My Header';
+ $this->email->addHeader('X-header', $value);
+
+ $this->assertEquals(array('X-header'=>$value), $this->email->model['customHeaders']);
+ }
+
+ public function testToMsysTransmission() {
+ $this->assertInternalType('array', $this->email->toMsysTransmission());
+ }
+}
+
+?> \ No newline at end of file
diff --git a/test/unit/SendGridCompatibiility/SendGridTest.php b/test/unit/SendGridCompatibiility/SendGridTest.php
new file mode 100644
index 0000000..15c5adc
--- /dev/null
+++ b/test/unit/SendGridCompatibiility/SendGridTest.php
@@ -0,0 +1,3 @@
+<?php
+
+?> \ No newline at end of file