diff options
-rw-r--r-- | composer.json | 5 | ||||
-rw-r--r-- | examples/transmission/configuration_based.php | 18 | ||||
-rw-r--r-- | examples/transmission/get_all_transmissions.php | 2 | ||||
-rw-r--r-- | examples/transmission/get_transmission.php | 2 | ||||
-rw-r--r-- | examples/transmission/rfc822.php | 20 | ||||
-rw-r--r-- | examples/transmission/send_transmission_all_fields.php | 30 | ||||
-rw-r--r-- | examples/transmission/stored_recipients_inline_content.php | 6 | ||||
-rw-r--r-- | examples/transmission/stored_template_send.php | 18 | ||||
-rw-r--r-- | lib/SendGridCompatibility/Email.php | 156 | ||||
-rw-r--r-- | lib/SendGridCompatibility/SendGrid.php | 24 | ||||
-rw-r--r-- | lib/SparkPost/SparkPost.php | 4 | ||||
-rw-r--r-- | lib/SparkPost/Transmission.php | 35 | ||||
-rw-r--r-- | test/unit/SendGridCompatibiility/EmailTest.php | 159 | ||||
-rw-r--r-- | test/unit/SendGridCompatibiility/SendGridTest.php | 3 | ||||
-rw-r--r-- | test/unit/SparkPostTest.php | 6 | ||||
-rw-r--r-- | test/unit/TransmissionTest.php | 26 |
16 files changed, 429 insertions, 85 deletions
diff --git a/composer.json b/composer.json index 44ac2cd..9c2f17f 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ ], "minimum-stability": "stable", "require": { - "php": ">=5.6.1", + "php": ">=5.3.0", "guzzlehttp/guzzle": "5.0.1" }, "require-dev": { @@ -18,7 +18,8 @@ }, "autoload": { "psr-4": { - "SparkPost\\": "lib/SparkPost/" + "SparkPost\\": "lib/SparkPost/", + "SparkPost\\SendGridCompatibility\\": "lib/SendGridCompatibility/" } } } diff --git a/examples/transmission/configuration_based.php b/examples/transmission/configuration_based.php index 81d61cf..8149238 100644 --- a/examples/transmission/configuration_based.php +++ b/examples/transmission/configuration_based.php @@ -6,22 +6,22 @@ use SparkPost\SparkPost; use SparkPost\Transmission; $key = 'YOURAPIKEY'; -SparkPost::setConfig(['key'=>$key]); +SparkPost::setConfig(array('key'=>$key)); try { - $results = Transmission::send([ + $results = Transmission::send(array( "from"=>"From Envelope <from@example.com>", "html"=>"<p>Hello World!</p>", "text"=>"Hello World!", "subject"=>"Example Email", - "recipients"=>[ - [ - "address"=>[ + "recipients"=>array( + array( + "address"=>array( "email"=>"john.doe@example.com" - ] - ] - ] - ]); + ) + ) + ) + )); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/transmission/get_all_transmissions.php b/examples/transmission/get_all_transmissions.php index c8c92e5..db06b68 100644 --- a/examples/transmission/get_all_transmissions.php +++ b/examples/transmission/get_all_transmissions.php @@ -6,7 +6,7 @@ use SparkPost\SparkPost; use SparkPost\Transmission; $key = 'YOURAPIKEY'; -SparkPost::setConfig(['key'=>$key]); +SparkPost::setConfig(array('key'=>$key)); try { $results = Transmission::all(); diff --git a/examples/transmission/get_transmission.php b/examples/transmission/get_transmission.php index 9c90b85..574388c 100644 --- a/examples/transmission/get_transmission.php +++ b/examples/transmission/get_transmission.php @@ -5,7 +5,7 @@ use SparkPost\SparkPost; use SparkPost\Transmission; $key = 'YOURAPIKEY'; -SparkPost::setConfig(['key'=>$key]); +SparkPost::setConfig(array('key'=>$key)); try { $results = Transmission::find('Your Transmission Id'); diff --git a/examples/transmission/rfc822.php b/examples/transmission/rfc822.php index 0635e15..b97bbb9 100644 --- a/examples/transmission/rfc822.php +++ b/examples/transmission/rfc822.php @@ -5,19 +5,19 @@ use SparkPost\SparkPost; use SparkPost\Transmission; $key = 'YOURAPIKEY'; -SparkPost::setConfig(['key'=>$key]); +SparkPost::setConfig(array('key'=>$key)); try { - $results = Transmission::send([ - 'recipients'=>[ - [ - 'address'=>[ + $results = Transmission::send(array( + 'recipients'=>array( + array( + 'address'=>array( 'email'=>'john.doe@sample.com' - ] - ] - ], - 'rfc822Part'=>"Content-Type: text/plain\nFrom: From Envelope <from@example.com>\nSubject: Example Email\n\nHello World" - ]); + ) + ) + ), + 'rfc822'=>"Content-Type: text/plain\nFrom: From Envelope <from@example.com>\nSubject: Example Email\n\nHello World" + )); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/transmission/send_transmission_all_fields.php b/examples/transmission/send_transmission_all_fields.php index fcfd344..30f7793 100644 --- a/examples/transmission/send_transmission_all_fields.php +++ b/examples/transmission/send_transmission_all_fields.php @@ -5,37 +5,37 @@ use SparkPost\SparkPost; use SparkPost\Transmission; $key = 'YOURAPIKEY'; -SparkPost::setConfig(['key'=>$key]); +SparkPost::setConfig(array('key'=>$key)); try{ - $results = Transmission::send([ + $results = Transmission::send(array( "campaign"=>"my-campaign", - "metadata"=>[ + "metadata"=>array( "sample_campaign"=>true, "type"=>"these are custom fields" - ], - "substitutionData"=>[ + ), + "substitutionData"=>array( "name"=>"Test Name" - ], + ), "description"=>"my description", "replyTo"=>"reply@test.com", - "customHeaders"=>[ + "customHeaders"=>array( "X-Custom-Header"=>"Sample Custom Header" - ], + ), "trackOpens"=>false, "trackClicks"=>false, "from"=>"From Envelope <from@example.com>", "html"=>"<p>Hello World! Your name is: {{name}}</p>", "text"=>"Hello World!", "subject"=>"Example Email: {{name}}", - "recipients"=>[ - [ - "address"=>[ + "recipients"=>array( + array( + "address"=>array( "email"=>"john.doe@sample.com" - ] - ] - ] - ]); + ) + ) + ) + )); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/examples/transmission/stored_recipients_inline_content.php b/examples/transmission/stored_recipients_inline_content.php index efd2b13..dbb7c1d 100644 --- a/examples/transmission/stored_recipients_inline_content.php +++ b/examples/transmission/stored_recipients_inline_content.php @@ -5,18 +5,18 @@ use SparkPost\SparkPost; use SparkPost\Transmission; $key = 'YOURAPIKEY'; -SparkPost::setConfig(['key'=>$key]); +SparkPost::setConfig(array('key'=>$key)); try { - $results = Transmission::send([ + $results = Transmission::send(array( "campaign"=>"my-campaign", "from"=>"From Envelope <from@example.com>", "html"=>"<p>Hello World! Your name is: {{name}}</p>", "text"=>"Hello World!", "subject"=>"Example Email: {{name}}", "recipientList"=>'Example List' - ]); + )); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { diff --git a/examples/transmission/stored_template_send.php b/examples/transmission/stored_template_send.php index 4d8ce49..cda6de6 100644 --- a/examples/transmission/stored_template_send.php +++ b/examples/transmission/stored_template_send.php @@ -5,20 +5,20 @@ use SparkPost\SparkPost; use SparkPost\Transmission; $key = 'YOURAPIKEY'; -SparkPost::setConfig(['key'=>$key]); +SparkPost::setConfig(array('key'=>$key)); try { - $results = Transmission::send([ + $results = Transmission::send(array( "from"=>"From Envelope <from@example.com>", - "recipients"=>[ - [ - "address"=>[ + "recipients"=>array( + array( + "address"=>array( "email"=>"john.doe@sample.com" - ] - ] - ], + ) + ) + ), "template"=>"my-template" - ]); + )); echo 'Congrats you can use your SDK!'; } catch (\Exception $exception) { echo $exception->getMessage(); diff --git a/lib/SendGridCompatibility/Email.php b/lib/SendGridCompatibility/Email.php new file mode 100644 index 0000000..e11c3ff --- /dev/null +++ b/lib/SendGridCompatibility/Email.php @@ -0,0 +1,156 @@ +<?php +namespace SparkPost\SendGridCompatibility; + +class Email { + public $model; + + public function __construct() { + $this->model = array(); + } + + public function addTo($address, $name = null) { + if (!isset($this->model['recipients'])) { + $this->model['recipients'] = array(); + } + + if(isset($name)) { + $address = array('address'=>array('email'=>$address, 'name'=>$name)); + } else { + $address = array('address'=>array('email'=>$address)); + } + + array_push($this->model['recipients'], $address); + return $this; + } + + public function setTos(array $addresses) { + $this->model['recipients'] = $addresses; + return $this; + } + + /** + * + * @param string $address + * @return \MessageSystems\SendGridCompatibility\Email + */ + public function setFrom($address) { + $this->model['from'] = array('email' => $address); + return $this; + } + + /** + * @param string $name + */ + public function setFromName($name) { + if(!isset($this->model['from'])){ + throw new \Exception('Must set "From" prior to setting "From Name".'); + } + $this->model['from']['name'] = $name; + return $this; + } + + /** + * + * @param string $address + * @return \MessageSystems\SendGridCompatibility\Email + */ + public function setReplyTo ($address) { + $this->model['replyTo'] = $address; + return $this; + } + + /** + * TODO: Does this work? + * + * + * @param string $address + * @return \MessageSystems\SendGridCompatibility\Email + */ + public function addBcc($address) { + if (!isset($this->model['bcc'])) { + $this->model['bcc'] = array(); + } + array_push($this->model['bcc'], $address); + return $this; + } + + public function setSubject($subject) { + $this->model['subject'] = $subject; + return $this; + } + + public function setText($text) { + $this->model['text'] = $text; + return $this; + } + + public function setHtml($html) { + $this->model['html'] = $html; + return $this; + } + + public function addCategory($category) { + if (!isset($this->model['tags'])) { + $this->model['tags'] = array(); + } + array_push($this->model['tags'], $category); + return $this; + } + + /** + * + * @throws Exception + * @param mixed $attachment + */ + public function addAttachment($attachment) { + throw new \Exception('Adding attachments is not yet supported'); + } + + /** + * @desc Sets the name attribute on the most recent set email address + * @param string $name + */ + public function addSubstitution($name, $values) { + if (!isset($this->model['substitutionData'])) { + $this->model['substitutionData'] = array(); + } + $this->model['substitutionData'][$name] = $values; + + return $this; + } + + public function addSection($name, $values) { + $this->addSubstitution($name, $values); + } + + /** + * + * @throws Exception + * @param mixed $attachment + */ + public function addUniqueArg($key, $value) { + throw new \Exception('Adding Unique Arguments is not yet supported'); + } + + /** + * + * @throws Exception + * @param mixed $attachment + */ + public function setUniqueArgs(array $values) { + throw new \Exception('Setting Unique Arguments is not yet supported'); + } + + + public function addHeader($name, $value) { + if (!isset($this->model['customHeaders'])) { + $this->model['customHeaders'] = array(); + } + $this->model['customHeaders'][$name] = $value; + } + + public function toMsysTransmission() { + return $this->model; + } +} +?>
\ No newline at end of file diff --git a/lib/SendGridCompatibility/SendGrid.php b/lib/SendGridCompatibility/SendGrid.php new file mode 100644 index 0000000..1fccda0 --- /dev/null +++ b/lib/SendGridCompatibility/SendGrid.php @@ -0,0 +1,24 @@ +<?php +namespace SparkPost\SendGridCompatibility; + +use SparkPost\Transmission; +use SparkPost\SendGridCompatibility\Email; +use SparkPost\Configuration; + +class SendGrid{ + private $sparkPost; + + public function __construct($username, $password, $options = null) { + //username isn't used in our system + $opts = array('key'=>$password); + if (!is_null($options)) { + $opts = array_merge($opts, $options); + } + Configuration::setConfig($opts); + } + + public function send(Email $email) { + Trasmission::send($email->toMsysTransmission()); + } +} +?>
\ No newline at end of file diff --git a/lib/SparkPost/SparkPost.php b/lib/SparkPost/SparkPost.php index 14af3cd..4228290 100644 --- a/lib/SparkPost/SparkPost.php +++ b/lib/SparkPost/SparkPost.php @@ -4,14 +4,14 @@ namespace SparkPost; class SparkPost { private static $config; - private static $defaults = [ + private static $defaults = array( 'host'=>'api.sparkpost.com', 'protocol'=>'https', 'port'=>443, 'strictSSL'=>true, 'key'=>'', 'version'=>'v1' - ]; + ); /** * Enforce that this object can't be instansiated diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php index 185f64b..8e6667a 100644 --- a/lib/SparkPost/Transmission.php +++ b/lib/SparkPost/Transmission.php @@ -17,7 +17,7 @@ class Transmission { * @desc Mapping for values passed into the send method to the values needed for the Transmission API * @var array */ - private static $parameterMappings = [ + private static $parameterMappings = array( 'campaign'=>'campaign_id', 'metadata'=>'metadata', 'substitutionData'=>'substitution_data', @@ -28,7 +28,7 @@ class Transmission { 'from'=>'content.from', 'html'=>'content.html', 'text'=>'content.text', - 'rfc822Part'=>'content.email_rfc822', + 'rfc822'=>'content.email_rfc822', 'customHeaders'=>'content.headers', 'recipients'=>'recipients', 'recipientList'=>'recipients.list_id', @@ -36,25 +36,25 @@ class Transmission { 'trackOpens'=>'options.open_tracking', 'trackClicks'=>'options.click_tracking', 'useDraftTemplate'=>'use_draft_template' - ]; + ); /** * @desc Sets up default structure and default values for the model that is acceptable by the API * @var array */ - private static $structure = [ + private static $structure = array( 'return_path'=>"default@sparkpostmail.com", - 'content'=>[ + 'content'=>array( 'html'=>null, 'text'=>null, 'email_rfc822'=>null - ], - 'options'=>[ + ), + 'options'=>array( 'open_tracking'=>true, 'click_tracking'=>true - ], + ), 'use_draft_template'=>false - ]; + ); /** * @desc Ensure that this class cannot be instansiated @@ -113,7 +113,7 @@ class Transmission { * 'from': string, * 'html': string, * 'text': string, - * 'rfc822Part': string, + * 'rfc822': string, * 'customHeaders': array, * 'recipients': array, * 'recipientList': string, @@ -136,15 +136,16 @@ class Transmission { //send the request try { - $response = $request->post(self::getBaseUrl($hostConfig), [ + $response = $request->post(self::getBaseUrl($hostConfig), array( 'json'=>$model, - "headers"=>['authorization' => $hostConfig['key']], + "headers"=>array('authorization' => $hostConfig['key']), "verify"=>$hostConfig['strictSSL'] - ]); + )); return $response->json(); } catch (RequestException $exception) { $response = $exception->getResponse(); - throw new \Exception(json_encode($response->json()['errors'])); + $responseArray = $response->json(); + throw new \Exception(json_encode($responseArray['errors'])); } catch (\Exception $exception) { throw new \Exception('Unable to contact Transmissions API: '. $exception->getMessage()); } @@ -174,10 +175,10 @@ class Transmission { //make request try { - $response = $request->get($url, [ - "headers"=>['authorization' => $hostConfig['key']], + $response = $request->get($url, array( + "headers"=>array('authorization' => $hostConfig['key']), "verify"=>$hostConfig['strictSSL'] - ]); + )); return $response->json(); } catch (RequestException $exception) { $response = $exception->getResponse(); 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 diff --git a/test/unit/SparkPostTest.php b/test/unit/SparkPostTest.php index cc1c9c9..650cb36 100644 --- a/test/unit/SparkPostTest.php +++ b/test/unit/SparkPostTest.php @@ -29,7 +29,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase { * @expectedExceptionMessage You must provide an API key */ public function testSetConfigAPIKeyNotSetException() { - SparkPost::setConfig(['something'=>'other than an API Key']); + SparkPost::setConfig(array('something'=>'other than an API Key')); } /** @@ -38,14 +38,14 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase { * @expectedExceptionMessage You must provide an API key */ public function testSetConfigAPIKeyEmptyException() { - SparkPost::setConfig(['key'=>'']); + SparkPost::setConfig(array('key'=>'')); } /** * @desc Tests overridable values are set while invalid values are ignored */ public function testSetConfigMultipleValuesAndGetConfig() { - SparkPost::setConfig(['key'=>'lala', 'version'=>'v8', 'port'=>1024, 'someOtherValue'=>'fakeValue']); + SparkPost::setConfig(array('key'=>'lala', 'version'=>'v8', 'port'=>1024, 'someOtherValue'=>'fakeValue')); $testConfig = SparkPost::getConfig(); $this->assertEquals('lala', $testConfig['key']); diff --git a/test/unit/TransmissionTest.php b/test/unit/TransmissionTest.php index 2a0bcfe..2945bc6 100644 --- a/test/unit/TransmissionTest.php +++ b/test/unit/TransmissionTest.php @@ -33,7 +33,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { * @see PHPUnit_Framework_TestCase::setUp() */ public function setUp() { - SparkPost::setConfig(['key'=>'blah']); + SparkPost::setConfig(array('key'=>'blah')); $this->client = self::getMethod('getHttpClient')->invoke(null); //so we can bootstrap api responses } @@ -49,9 +49,9 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { * @desc tests happy path */ public function testAllWithGoodResponse() { - $mock = new Mock([new Response(200, [], Stream::factory('{"results":[{"test":"This is a test"}, {"test":"two"}]}'))]); + $mock = new Mock(array(new Response(200, array(), Stream::factory('{"results":[{"test":"This is a test"}, {"test":"two"}]}')))); $this->client->getEmitter()->attach($mock); - $this->assertEquals(["results"=>[['test'=>'This is a test'], ['test'=>'two']]], Transmission::all()); + $this->assertEquals(array("results"=>array(array('test'=>'This is a test'), array('test'=>'two'))), Transmission::all()); $this->client->getEmitter()->detach($mock); } @@ -59,9 +59,9 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { * @desc tests happy path */ public function testFindWithGoodResponse() { - $mock = new Mock([new Response(200, [], Stream::factory('{"results":[{"test":"This is a test"}]}'))]); + $mock = new Mock(array(new Response(200, array(), Stream::factory('{"results":[{"test":"This is a test"}]}')))); $this->client->getEmitter()->attach($mock); - $this->assertEquals(["results"=>[['test'=>'This is a test']]], Transmission::find('someId')); + $this->assertEquals(array("results"=>array(array('test'=>'This is a test'))), Transmission::find('someId')); $this->client->getEmitter()->detach($mock); } @@ -69,7 +69,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { * @desc tests 404 bad response */ public function testFindWith404Response() { - $mock = new Mock([new Response(404, [])]); + $mock = new Mock(array(new Response(404, array()))); $this->client->getEmitter()->attach($mock); try { Transmission::find('someId'); @@ -84,7 +84,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { * @desc tests unknown bad response */ public function testFindWithOtherBadResponse() { - $mock = new Mock([new Response(400, [])]); + $mock = new Mock(array(new Response(400, array()))); $this->client->getEmitter()->attach($mock); try { Transmission::find('someId'); @@ -99,10 +99,10 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { * @desc tests happy path */ public function testSuccessfulSend() { - $body = ["result"=>["transmission_id"=> "11668787484950529"], "status"=>["message"=> "ok","code"=> "1000"]]; - $mock = new Mock([new Response(200, [], Stream::factory(json_encode($body)))]); + $body = array("result"=>array("transmission_id"=>"11668787484950529"), "status"=>array("message"=> "ok","code"=> "1000")); + $mock = new Mock(array(new Response(200, array(), Stream::factory(json_encode($body))))); $this->client->getEmitter()->attach($mock); - $this->assertEquals($body, Transmission::send(['text'=>'awesome email'])); + $this->assertEquals($body, Transmission::send(array('text'=>'awesome email'))); $this->client->getEmitter()->detach($mock); } @@ -110,11 +110,11 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase { * @desc tests bad response */ public function testSendForRequestException() { - $body = ['errors'=>['This is a fake error']]; - $mock = new Mock([new Response(400, [], Stream::factory(json_encode($body)))]); + $body = array('errors'=>array('This is a fake error')); + $mock = new Mock(array(new Response(400, array(), Stream::factory(json_encode($body))))); $this->client->getEmitter()->attach($mock); try { - Transmission::send(['text'=>'awesome email']); + Transmission::send(array('text'=>'awesome email')); } catch (\Exception $e) { $this->assertEquals('["This is a fake error"]', $e->getMessage()); } finally { |