diff options
author | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-22 11:44:41 -0400 |
---|---|---|
committer | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-22 11:44:41 -0400 |
commit | d7f6b4b22e569ed0da339a9228f4202304fe7a05 (patch) | |
tree | 8f4da3d82e2b3eca9d60131ec768f3a5065382b9 | |
parent | 9f86fd39e85e7d3736b9b5c7ea5e95f5129773f4 (diff) | |
download | php-sparkpost-d7f6b4b22e569ed0da339a9228f4202304fe7a05.zip php-sparkpost-d7f6b4b22e569ed0da339a9228f4202304fe7a05.tar.gz php-sparkpost-d7f6b4b22e569ed0da339a9228f4202304fe7a05.tar.bz2 |
formatting and comments
-rw-r--r-- | lib/SparkPost/Resource.php | 21 | ||||
-rw-r--r-- | lib/SparkPost/SparkPostException.php | 2 | ||||
-rw-r--r-- | lib/SparkPost/SparkPostPromise.php | 11 | ||||
-rw-r--r-- | lib/SparkPost/SparkPostResponse.php | 6 | ||||
-rw-r--r-- | lib/SparkPost/Transmission.php | 69 | ||||
-rw-r--r-- | test/unit/SparkPostResponseTest.php | 97 | ||||
-rw-r--r-- | test/unit/SparkPostTest.php | 42 | ||||
-rw-r--r-- | test/unit/TransmissionTest.php | 30 |
8 files changed, 129 insertions, 149 deletions
diff --git a/lib/SparkPost/Resource.php b/lib/SparkPost/Resource.php index bc6f78d..7fab937 100644 --- a/lib/SparkPost/Resource.php +++ b/lib/SparkPost/Resource.php @@ -5,17 +5,17 @@ namespace SparkPost; class Resource { /** - * SparkPost object used to make requests + * SparkPost object used to make requests. */ protected $sparkpost; /** - * The api endpoint that gets prepended to all requests send through this resource + * The api endpoint that gets prepended to all requests send through this resource. */ protected $endpoint; /** - * Sets up the Resource + * Sets up the Resource. * * @param SparKPost $sparkpost - the sparkpost instance that this resource is attached to * @param string $endpoint - the endpoint that this resource wraps @@ -27,7 +27,7 @@ class Resource } /** - * Sends get request to API at the set endpoint + * Sends get request to API at the set endpoint. * * @see SparkPost->request() */ @@ -37,7 +37,7 @@ class Resource } /** - * Sends put request to API at the set endpoint + * Sends put request to API at the set endpoint. * * @see SparkPost->request() */ @@ -47,7 +47,7 @@ class Resource } /** - * Sends post request to API at the set endpoint + * Sends post request to API at the set endpoint. * * @see SparkPost->request() */ @@ -57,7 +57,7 @@ class Resource } /** - * Sends delete request to API at the set endpoint + * Sends delete request to API at the set endpoint. * * @see SparkPost->request() */ @@ -67,7 +67,7 @@ class Resource } /** - * Sends requests to SparkPost object to the resource endpoint + * Sends requests to SparkPost object to the resource endpoint. * * @see SparkPost->request() * @@ -75,7 +75,6 @@ class Resource */ public function request($method = 'GET', $uri = '', $payload = [], $headers = []) { - if (is_array($uri)) { $headers = $payload; $payload = $uri; @@ -83,7 +82,7 @@ class Resource } $uri = $this->endpoint.'/'.$uri; - + return $this->sparkpost->request($method, $uri, $payload, $headers); } -}
\ No newline at end of file +} diff --git a/lib/SparkPost/SparkPostException.php b/lib/SparkPost/SparkPostException.php index f1e3146..ca92e24 100644 --- a/lib/SparkPost/SparkPostException.php +++ b/lib/SparkPost/SparkPostException.php @@ -38,4 +38,4 @@ class SparkPostException extends \Exception { return $this->body; } -}
\ No newline at end of file +} diff --git a/lib/SparkPost/SparkPostPromise.php b/lib/SparkPost/SparkPostPromise.php index 15f129f..df715d5 100644 --- a/lib/SparkPost/SparkPostPromise.php +++ b/lib/SparkPost/SparkPostPromise.php @@ -29,12 +29,14 @@ class SparkPostPromise implements HttpPromise */ public function then(callable $onFulfilled = null, callable $onRejected = null) { - return $this->promise->then(function($response) use ($onFulfilled) { - if (isset($onFulfilled)) + return $this->promise->then(function ($response) use ($onFulfilled) { + if (isset($onFulfilled)) { $onFulfilled(new SparkPostResponse($response)); - }, function($exception) use ($onRejected) { - if (isset($onRejected)) + } + }, function ($exception) use ($onRejected) { + if (isset($onRejected)) { $onRejected(new SparkPostException($exception)); + } }); } @@ -61,6 +63,7 @@ class SparkPostPromise implements HttpPromise { try { $response = $this->promise->wait($unwrap); + return $response ? new SparkPostResponse($response) : $response; } catch (\Exception $exception) { throw new SparkPostException($exception); diff --git a/lib/SparkPost/SparkPostResponse.php b/lib/SparkPost/SparkPostResponse.php index 9104b33..08750f9 100644 --- a/lib/SparkPost/SparkPostResponse.php +++ b/lib/SparkPost/SparkPostResponse.php @@ -34,10 +34,12 @@ class SparkPostResponse implements ResponseInterface $json = json_decode($body_string, true); - return $json; + return $json; } - // pass these down to the response given in the constructor + /** + * pass these down to the response given in the constructor + */ public function getProtocolVersion() { return $this->response->getProtocolVersion(); diff --git a/lib/SparkPost/Transmission.php b/lib/SparkPost/Transmission.php index f136d5b..1847e1b 100644 --- a/lib/SparkPost/Transmission.php +++ b/lib/SparkPost/Transmission.php @@ -10,24 +10,26 @@ class Transmission extends Resource } /** - * Send post request to transmission endpoint after formatting cc, bcc, and expanding the shorthand emails + * Send post request to transmission endpoint after formatting cc, bcc, and expanding the shorthand emails. * * @return SparkPostPromise or SparkPostResponse depending on sync or async request */ public function post($payload = [], $headers = []) { $payload = $this->formatPayload($payload); + return parent::post($payload, $headers); } /** - * Runs the given payload through the formatting functions + * Runs the given payload through the formatting functions. * * @param array $payload - the request body * * @return array - the modified request body */ - public function formatPayload($payload) { + public function formatPayload($payload) + { $payload = $this->formatBlindCarbonCopy($payload); //Fixes BCCs into payload $payload = $this->formatCarbonCopy($payload); //Fixes CCs into payload $payload = $this->formatShorthandRecipients($payload); //Fixes shorthand recipients format @@ -36,7 +38,7 @@ class Transmission extends Resource } /** - * Formats bcc list into recipients list + * Formats bcc list into recipients list. * * @param array $payload - the request body * @@ -44,9 +46,9 @@ class Transmission extends Resource */ private function formatBlindCarbonCopy($payload) { - + //If there's a list of BCC recipients, move then into the correct format - if(isset($payload['bcc'])) { + if (isset($payload['bcc'])) { $payload = $this->addListToRecipients($payload, 'bcc'); } @@ -54,7 +56,7 @@ class Transmission extends Resource } /** - * Formats cc list into recipients list and adds the CC header to the content + * Formats cc list into recipients list and adds the CC header to the content. * * @param array $payload - the request body * @@ -62,9 +64,9 @@ class Transmission extends Resource */ private function formatCarbonCopy($payload) { - if(isset($payload['cc'])) { + if (isset($payload['cc'])) { $ccAddresses = []; - for ($i = 0; $i < count($payload['cc']); $i++) { + for ($i = 0; $i < count($payload['cc']); ++$i) { array_push($ccAddresses, $this->toAddressString($payload['cc'][$i]['address'])); } @@ -80,7 +82,7 @@ class Transmission extends Resource } /** - * Formats all recipients into the long form of [ "name" => "John", "email" => "john@exmmple.com" ] + * Formats all recipients into the long form of [ "name" => "John", "email" => "john@exmmple.com" ]. * * @param array $payload - the request body * @@ -88,10 +90,9 @@ class Transmission extends Resource */ private function formatShorthandRecipients($payload) { - $payload['content']['from'] = $this->toAddressObject($payload['content']['from']); - - for($i = 0; $i < count($payload['recipients']); $i++) { + + for ($i = 0; $i < count($payload['recipients']); ++$i) { $payload['recipients'][$i]['address'] = $this->toAddressObject($payload['recipients'][$i]['address']); } @@ -99,7 +100,7 @@ class Transmission extends Resource } /** - * Loops through the given listName in the payload and adds all the recipients to the recipients list after removing their names + * Loops through the given listName in the payload and adds all the recipients to the recipients list after removing their names. * * @param array $payload - the request body * @param array $listName - the name of the array in the payload to be moved to the recipients list @@ -112,14 +113,15 @@ class Transmission extends Resource foreach ($payload[$listName] as $recipient) { $recipient['address'] = $this->toAddressObject($recipient['address']); $recipient['address']['header_to'] = $originalAddress; - + // remove name from address - name is only put in the header for cc and not at all for bcc - if (isset($recipient['address']['name'])) + if (isset($recipient['address']['name'])) { unset($recipient['address']['name']); + } array_push($payload['recipients'], $recipient); } - + //Delete the original object from the payload. unset($payload[$listName]); @@ -127,7 +129,7 @@ class Transmission extends Resource } /** - * Takes the shorthand form of an email address and converts it to the long form + * Takes the shorthand form of an email address and converts it to the long form. * * @param $address - the shorthand form of an email address "Name <Email address>" * @@ -141,37 +143,32 @@ class Transmission extends Resource if ($this->isEmail($address)) { $return['email'] = $address; - } - else if(preg_match('/"?(.[^"]+)"?\s*<(.+)>/', $address, $matches)) { + } elseif (preg_match('/"?(.[^"]*)?"?\s*<(.+)>/', $address, $matches)) { $name = trim($matches[1]); $return['name'] = $matches[1]; $return['email'] = $matches[2]; - } - else { + } else { throw new \Exception('Invalid address format: '.$address); } - } return $return; } /** - * Takes the longhand form of an email address and converts it to the shorthand form + * Takes the longhand form of an email address and converts it to the shorthand form. * * @param $address - the longhand form of an email address [ "name" => "John", "email" => "john@exmmple.com" ] - * * @param string - the shorthand form of an email address "Name <Email address>" */ private function toAddressString($address) { // convert object to string - if(!is_string($address)) { + if (!is_string($address)) { if (isset($address['name'])) { - $address = '"' . $address['name'] . '" <' . $address['email'] . '>'; - } - else { - $address = $address['email']; + $address = '"'.$address['name'].'" <'.$address['email'].'>'; + } else { + $address = $address['email']; } } @@ -179,19 +176,17 @@ class Transmission extends Resource } /** - * Checks if a string is an email + * Checks if a string is an email. * * @param string $email - a string that might be an email address - * - * @param boolean - true if the given string is an email + * @param bool - true if the given string is an email */ - private function isEmail($email){ - if(filter_var($email, FILTER_VALIDATE_EMAIL)){ + private function isEmail($email) + { + if (filter_var($email, FILTER_VALIDATE_EMAIL)) { return true; } else { return false; } } } - -?>
\ No newline at end of file diff --git a/test/unit/SparkPostResponseTest.php b/test/unit/SparkPostResponseTest.php index db8600a..efdec1a 100644 --- a/test/unit/SparkPostResponseTest.php +++ b/test/unit/SparkPostResponseTest.php @@ -1,14 +1,13 @@ <?php + namespace SparkPost\Test; use SparkPost\SparkPostResponse; -use Psr\Http\Message\StreamInterface; -use Psr\Http\Message\ResponseInterface; use Mockery; class SparkPostResponseTest extends \PHPUnit_Framework_TestCase { - /** + /** * (non-PHPdoc). * * @before @@ -17,120 +16,118 @@ class SparkPostResponseTest extends \PHPUnit_Framework_TestCase */ public function setUp() { - $this->returnValue = 'some_value_to_return'; + $this->returnValue = 'some_value_to_return'; $this->responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface'); } public function testGetProtocolVersion() - { - $this->responseMock->shouldReceive('getProtocolVersion')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + { + $this->responseMock->shouldReceive('getProtocolVersion')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->getProtocolVersion(), $sparkpostResponse->getProtocolVersion()); } public function testWithProtocolVersion() - { - $param = 'protocol version'; + { + $param = 'protocol version'; - $this->responseMock->shouldReceive('withProtocolVersion')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('withProtocolVersion')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->withProtocolVersion($param), $sparkpostResponse->withProtocolVersion($param)); } public function testGetHeaders() - { - $this->responseMock->shouldReceive('getHeaders')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + { + $this->responseMock->shouldReceive('getHeaders')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->getHeaders(), $sparkpostResponse->getHeaders()); } public function testHasHeader() - { - $param = 'header'; + { + $param = 'header'; - $this->responseMock->shouldReceive('hasHeader')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('hasHeader')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->hasHeader($param), $sparkpostResponse->hasHeader($param)); } public function testGetHeader() { - $param = 'header'; + $param = 'header'; - $this->responseMock->shouldReceive('getHeader')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('getHeader')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->getHeader($param), $sparkpostResponse->getHeader($param)); } public function testGetHeaderLine() { - $param = 'header'; + $param = 'header'; - $this->responseMock->shouldReceive('getHeaderLine')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('getHeaderLine')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->getHeaderLine($param), $sparkpostResponse->getHeaderLine($param)); } public function testWithHeader() { - $param = 'header'; - $param2 = 'value'; + $param = 'header'; + $param2 = 'value'; - $this->responseMock->shouldReceive('withHeader')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('withHeader')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->withHeader($param, $param2), $sparkpostResponse->withHeader($param, $param2)); } public function testWithAddedHeader() { - $param = 'header'; - $param2 = 'value'; - + $param = 'header'; + $param2 = 'value'; - $this->responseMock->shouldReceive('withAddedHeader')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('withAddedHeader')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->withAddedHeader($param, $param2), $sparkpostResponse->withAddedHeader($param, $param2)); } public function testWithoutHeader() - { - $param = 'header'; + { + $param = 'header'; - $this->responseMock->shouldReceive('withoutHeader')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('withoutHeader')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->withoutHeader($param), $sparkpostResponse->withoutHeader($param)); } public function testWithBody() { - $param = Mockery::mock('Psr\Http\Message\StreamInterface'); + $param = Mockery::mock('Psr\Http\Message\StreamInterface'); - $this->responseMock->shouldReceive('withBody')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('withBody')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->withBody($param), $sparkpostResponse->withBody($param)); } public function testGetStatusCode() - { - $this->responseMock->shouldReceive('getStatusCode')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + { + $this->responseMock->shouldReceive('getStatusCode')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->getStatusCode(), $sparkpostResponse->getStatusCode()); } public function testWithStatus() { - $param = 'status'; + $param = 'status'; - $this->responseMock->shouldReceive('withStatus')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + $this->responseMock->shouldReceive('withStatus')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->withStatus($param), $sparkpostResponse->withStatus($param)); } public function testGetReasonPhrase() - { - $this->responseMock->shouldReceive('getReasonPhrase')->andReturn($this->returnValue); - $sparkpostResponse = new SparkPostResponse($this->responseMock); + { + $this->responseMock->shouldReceive('getReasonPhrase')->andReturn($this->returnValue); + $sparkpostResponse = new SparkPostResponse($this->responseMock); $this->assertEquals($this->responseMock->getReasonPhrase(), $sparkpostResponse->getReasonPhrase()); } } -?>
\ No newline at end of file diff --git a/test/unit/SparkPostTest.php b/test/unit/SparkPostTest.php index c5dca08..f1c8a56 100644 --- a/test/unit/SparkPostTest.php +++ b/test/unit/SparkPostTest.php @@ -3,16 +3,10 @@ namespace SparkPost\Test; use SparkPost\SparkPost; -use SparkPost\SparkPostResponse; use SparkPost\SparkPostPromise; -use Psr\Http\Message\ResponseInterface; -use Http\Promise\Promise; -use GuzzleHttp\Promise\Promise as GuzzlePromise; use GuzzleHttp\Promise\FulfilledPromise as GuzzleFulfilledPromise; use GuzzleHttp\Promise\RejectedPromise as GuzzleRejectedPromise; use Http\Adapter\Guzzle6\Promise as GuzzleAdapterPromise; -use Http\Client\Exception\HttpException; -use Http\Adapter\Guzzle6\Client; use Mockery; use SparkPost\Test\TestUtils\ClassUtils; @@ -25,18 +19,18 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase private $postTransmissionPayload = [ 'content' => [ - 'from' => [ 'name' => 'Sparkpost Team', 'email' => 'postmaster@sendmailfor.me' ], + 'from' => ['name' => 'Sparkpost Team', 'email' => 'postmaster@sendmailfor.me'], 'subject' => 'First Mailing From PHP', 'text' => 'Congratulations, {{name}}!! You just sent your very first mailing!', ], 'substitution_data' => ['name' => 'Avi'], 'recipients' => [ - ['address' => 'avi.goldman@sparkpost.com'] - ] + ['address' => 'avi.goldman@sparkpost.com'], + ], ]; - + private $getTransmissionPayload = [ - 'campaign_id' => 'thanksgiving' + 'campaign_id' => 'thanksgiving', ]; /** @@ -60,12 +54,12 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase Mockery::close(); } - public function testRequest() { + public function testRequest() + { $responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface'); $this->resource->setOptions(['async' => false]); $this->resource->httpClient->shouldReceive('sendRequest')->andReturn($responseMock); $this->assertInstanceOf('SparkPost\SparkPostResponse', $this->resource->request('POST', 'transmissions', $this->postTransmissionPayload)); - $promiseMock = Mockery::mock('Http\Promise\Promise'); $this->resource->setOptions(['async' => true]); @@ -155,7 +149,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase once()-> with(Mockery::type('GuzzleHttp\Psr7\Request'))-> andReturn($promiseMock); - + $promiseMock->shouldReceive('wait')->andThrow($exceptionMock); $exceptionMock->shouldReceive('getResponse->getStatusCode')->andReturn(500); @@ -171,7 +165,8 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase } } - public function testSuccessfulAsyncRequestWithThen() { + public function testSuccessfulAsyncRequestWithThen() + { $responseBody = ['results' => 'yay']; $responseMock = Mockery::mock('Psr\Http\Message\ResponseInterface'); $responseBodyMock = Mockery::mock(); @@ -180,26 +175,27 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase $responseBodyMock->shouldReceive('__toString')->andReturn(json_encode($responseBody)); $guzzlePromise = new GuzzleFulfilledPromise($responseMock); - + $promise = new SparkPostPromise(new GuzzleAdapterPromise($guzzlePromise, $this->resource->buildRequest('POST', 'transmissions', $this->postTransmissionPayload, []))); - $promise->then(function ($exception) use ($responseBody) { + $promise->then(function ($exception) use ($responseBody) { $this->assertEquals(200, $exception->getStatusCode()); $this->assertEquals($responseBody, $exception->getBody()); }, null)->wait(); } - public function testUnsuccessfulAsyncRequestWithThen() { + public function testUnsuccessfulAsyncRequestWithThen() + { $responseBody = ['results' => 'failed']; $exceptionMock = Mockery::mock('Http\Client\Exception\HttpException'); $exceptionMock->shouldReceive('getResponse->getStatusCode')->andReturn(500); $exceptionMock->shouldReceive('getResponse->getBody->__toString')->andReturn(json_encode($responseBody)); $guzzlePromise = new GuzzleRejectedPromise($exceptionMock); - + $promise = new SparkPostPromise(new GuzzleAdapterPromise($guzzlePromise, $this->resource->buildRequest('POST', 'transmissions', $this->postTransmissionPayload, []))); - $promise->then(null, function ($exception) use ($responseBody) { + $promise->then(null, function ($exception) use ($responseBody) { $this->assertEquals(500, $exception->getCode()); $this->assertEquals($responseBody, $exception->getBody()); })->wait(); @@ -220,7 +216,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase $this->assertEquals($promiseMock->getState(), $promise->getState()); $promiseMock->shouldReceive('getState')->once()->andReturn('rejected'); - $this->assertEquals('rejected', $promise->getState()); + $this->assertEquals('rejected', $promise->getState()); } /** @@ -228,7 +224,6 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase */ public function testUnsupportedAsyncRequest() { - $this->resource->setHttpClient(Mockery::mock('Http\Client\HttpClient')); $this->resource->asyncRequest('POST', 'transmissions', $this->postTransmissionPayload); @@ -237,7 +232,7 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase public function testGetHttpHeaders() { $headers = $this->resource->getHttpHeaders([ - 'Custom-Header' => 'testing' + 'Custom-Header' => 'testing', ]); $version = self::$utils->getProperty($this->resource, 'version'); @@ -276,5 +271,4 @@ class SparkPostTest extends \PHPUnit_Framework_TestCase self::$utils->setProperty($this->resource, 'options', []); $this->resource->setOptions(['not' => 'SPARKPOST_API_KEY']); } - } diff --git a/test/unit/TransmissionTest.php b/test/unit/TransmissionTest.php index f0a8ec9..84f16f0 100644 --- a/test/unit/TransmissionTest.php +++ b/test/unit/TransmissionTest.php @@ -3,16 +3,6 @@ namespace SparkPost\Test; use SparkPost\SparkPost; -use SparkPost\SparkPostResponse; -use SparkPost\SparkPostPromise; -use Psr\Http\Message\ResponseInterface; -use Http\Promise\Promise; -use GuzzleHttp\Promise\Promise as GuzzlePromise; -use GuzzleHttp\Promise\FulfilledPromise as GuzzleFulfilledPromise; -use GuzzleHttp\Promise\RejectedPromise as GuzzleRejectedPromise; -use Http\Adapter\Guzzle6\Promise as GuzzleAdapterPromise; -use Http\Client\Exception\HttpException; -use Http\Adapter\Guzzle6\Client; use Mockery; use SparkPost\Test\TestUtils\ClassUtils; @@ -25,7 +15,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase private $postTransmissionPayload = [ 'content' => [ - 'from' => [ 'name' => 'Sparkpost Team', 'email' => 'postmaster@sendmailfor.me' ], + 'from' => ['name' => 'Sparkpost Team', 'email' => 'postmaster@sendmailfor.me'], 'subject' => 'First Mailing From PHP', 'text' => 'Congratulations, {{name}}!! You just sent your very first mailing!', ], @@ -34,26 +24,26 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase [ 'address' => [ 'name' => 'Vincent', - 'email' => 'vincent.song@sparkpost.com' - ] + 'email' => 'vincent.song@sparkpost.com', + ], ], - [ 'address' => 'test@example.com' ] + ['address' => 'test@example.com'], ], 'cc' => [ [ 'address' => [ - 'email' => 'avi.goldman@sparkpost.com' + 'email' => 'avi.goldman@sparkpost.com', ], - ] + ], ], 'bcc' => [ ['address' => 'Emely Giraldo <emely.giraldo@sparkpost.com>'], - ] + ], ]; - + private $getTransmissionPayload = [ - 'campaign_id' => 'thanksgiving' + 'campaign_id' => 'thanksgiving', ]; /** @@ -83,7 +73,7 @@ class TransmissionTest extends \PHPUnit_Framework_TestCase public function testInvalidEmailFormat() { $this->postTransmissionPayload['recipients'][] = [ - 'address' => 'invalid email format' + 'address' => 'invalid email format', ]; $response = $this->resource->transmissions->post($this->postTransmissionPayload); |