diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/APIResourceTest.php | 16 | ||||
-rw-r--r-- | test/unit/SendGridCompatibiility/EmailTest.php | 310 | ||||
-rw-r--r-- | test/unit/SparkPostTest.php | 12 | ||||
-rw-r--r-- | test/unit/TransmissionTest.php | 8 |
4 files changed, 173 insertions, 173 deletions
diff --git a/test/unit/APIResourceTest.php b/test/unit/APIResourceTest.php index b64093d..8253b1e 100644 --- a/test/unit/APIResourceTest.php +++ b/test/unit/APIResourceTest.php @@ -19,11 +19,11 @@ class APIResourceTest extends \PHPUnit_Framework_TestCase { } /** - * (non-PHPdoc) - * @before - * @see PHPUnit_Framework_TestCase::setUp() - */ - public function setUp() { + * (non-PHPdoc) + * @before + * @see PHPUnit_Framework_TestCase::setUp() + */ + public function setUp() { $this->sparkPostMock = Mockery::mock('SparkPost\SparkPost', function($mock) { $mock->shouldReceive('getHttpHeaders')->andReturn([]); }); @@ -45,7 +45,7 @@ class APIResourceTest extends \PHPUnit_Framework_TestCase { public function testCreate() { $testInput = ['test'=>'body']; - $testBody = ["results"=>["my"=>"test"]]; + $testBody = ['results'=>['my'=>'test']]; $responseMock = Mockery::mock(); $this->sparkPostMock->httpAdapter->shouldReceive('send')-> once()-> @@ -59,7 +59,7 @@ class APIResourceTest extends \PHPUnit_Framework_TestCase { public function testUpdate() { $testInput = ['test'=>'body']; - $testBody = ["results"=>["my"=>"test"]]; + $testBody = ['results'=>['my'=>'test']]; $responseMock = Mockery::mock(); $this->sparkPostMock->httpAdapter->shouldReceive('send')-> once()-> @@ -71,7 +71,7 @@ class APIResourceTest extends \PHPUnit_Framework_TestCase { } public function testGet() { - $testBody = ["results"=>["my"=>"test"]]; + $testBody = ['results'=>['my'=>'test']]; $responseMock = Mockery::mock(); $this->sparkPostMock->httpAdapter->shouldReceive('send')-> once()-> diff --git a/test/unit/SendGridCompatibiility/EmailTest.php b/test/unit/SendGridCompatibiility/EmailTest.php index 1c7311d..2b86d7a 100644 --- a/test/unit/SendGridCompatibiility/EmailTest.php +++ b/test/unit/SendGridCompatibiility/EmailTest.php @@ -2,160 +2,160 @@ 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']); - } - /** - * @expectedException Exception - * @expectedExceptionMessage Adding bcc recipients is not yet supported, try adding them as a "to" address - */ - public function testAddBcc() { - $this->email->addBcc('test@email.com'); - } - - 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']); - } - - /** - * @desc test that adding a category throws an exception since we don't support tags at transmission level yet - * @expectedException Exception - * @expectedExceptionMessage Adding categories is not yet supported - */ - public function testAddCategory() { - $this->email->addCategory(''); - } - - /** - * @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(array('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 testToSparkPostTransmission() { - $this->assertInternalType('array', $this->email->toSparkPostTransmission()); - } + + 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']); + } + /** + * @expectedException Exception + * @expectedExceptionMessage Adding bcc recipients is not yet supported, try adding them as a 'to' address + */ + public function testAddBcc() { + $this->email->addBcc('test@email.com'); + } + + 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']); + } + + /** + * @desc test that adding a category throws an exception since we don't support tags at transmission level yet + * @expectedException Exception + * @expectedExceptionMessage Adding categories is not yet supported + */ + public function testAddCategory() { + $this->email->addCategory(''); + } + + /** + * @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(array('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 testToSparkPostTransmission() { + $this->assertInternalType('array', $this->email->toSparkPostTransmission()); + } } -?>
\ No newline at end of file +?> diff --git a/test/unit/SparkPostTest.php b/test/unit/SparkPostTest.php index cd45c5a..d4b1129 100644 --- a/test/unit/SparkPostTest.php +++ b/test/unit/SparkPostTest.php @@ -34,14 +34,14 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase { } /** - * @desc Ensures that the configuration class is not instantiable. - */ - public function testConstructorSetsUpTransmissions() { - $sparky = new SparkPost(new CurlHttpAdapter(), ['key'=>'a key']); - $this->assertEquals('SparkPost\Transmission', get_class($sparky->transmission)); + * @desc Ensures that the configuration class is not instantiable. + */ + public function testConstructorSetsUpTransmissions() { + $sparky = new SparkPost(new CurlHttpAdapter(), ['key'=>'a key']); + $this->assertEquals('SparkPost\Transmission', get_class($sparky->transmission)); $adapter = self::$utils->getProperty($this->resource, 'httpAdapter'); $this->assertRegExp('/php-sparkpost.*/', $adapter->getConfiguration()->getUserAgent()); - } + } /** * @expectedException Exception diff --git a/test/unit/TransmissionTest.php b/test/unit/TransmissionTest.php index f09db7d..d262ee0 100644 --- a/test/unit/TransmissionTest.php +++ b/test/unit/TransmissionTest.php @@ -31,7 +31,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { public function testSend() { $responseMock = Mockery::mock(); $body = ['text'=>'awesomesauce', 'content'=>['subject'=>'awesomeness']]; - $responseBody = ["results"=>"yay"]; + $responseBody = ['results'=>'yay']; $this->sparkPostMock->httpAdapter->shouldReceive('send')-> once()-> @@ -45,7 +45,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { public function testAllWithFilter() { $responseMock = Mockery::mock(); - $responseBody = ["results"=>"yay"]; + $responseBody = ['results'=>'yay']; $this->sparkPostMock->httpAdapter->shouldReceive('send')-> once()-> with('/.*transmissions.*?campaign_id=campaign&template_id=template/', 'GET', Mockery::type('array'), null)-> @@ -58,7 +58,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { public function testAllWithOutFilter() { $responseMock = Mockery::mock(); - $responseBody = ["results"=>"yay"]; + $responseBody = ['results'=>'yay']; $this->sparkPostMock->httpAdapter->shouldReceive('send')-> once()-> with('/.*\/transmissions/', 'GET', Mockery::type('array'), null)-> @@ -71,7 +71,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { public function testFind() { $responseMock = Mockery::mock(); - $responseBody = ["results"=>"yay"]; + $responseBody = ['results'=>'yay']; $this->sparkPostMock->httpAdapter->shouldReceive('send')-> once()-> with('/.*\/transmissions.*\/test/', 'GET', Mockery::type('array'), null)-> |