This commit is contained in:
Nyholm 2018-08-05 12:00:05 +02:00 committed by David Garcia
parent 1ed1c2557c
commit 1835bc28d7
9 changed files with 27 additions and 58 deletions

View File

@ -11,8 +11,6 @@ namespace Mailgun\Tests\Api;
use GuzzleHttp\Psr7\Response;
use Mailgun\Api\Domain;
use Mailgun\Api\Event;
use Mailgun\Exception\InvalidArgumentException;
use Mailgun\Model\Domain\ConnectionResponse;
use Mailgun\Model\Domain\CreateCredentialResponse;
use Mailgun\Model\Domain\CreateResponse;
@ -23,7 +21,6 @@ use Mailgun\Model\Domain\ShowResponse;
use Mailgun\Model\Domain\UpdateConnectionResponse;
use Mailgun\Model\Domain\UpdateCredentialResponse;
use Mailgun\Model\Domain\VerifyResponse;
use Mailgun\Model\Event\EventResponse;
class DomainTest extends TestCase
{
@ -77,7 +74,7 @@ JSON
$this->setRequestMethod('POST');
$this->setRequestUri('/v3/domains');
$this->setRequestBody([
'name'=>'example.com'
'name' => 'example.com',
]);
$this->setHydrateClass(CreateResponse::class);
@ -90,9 +87,9 @@ JSON
$this->setRequestMethod('POST');
$this->setRequestUri('/v3/domains');
$this->setRequestBody([
'name'=>'example.com',
'smtp_password'=>'foo',
'spam_action'=>'bar',
'name' => 'example.com',
'smtp_password' => 'foo',
'spam_action' => 'bar',
]);
$this->setHydrateClass(CreateResponse::class);
@ -136,6 +133,7 @@ JSON
$api = $this->getApiInstance();
$api->updateCredential('example.com', 'foo', 'barbar');
}
public function testDeleteCredential()
{
$this->setRequestMethod('DELETE');
@ -167,10 +165,9 @@ JSON
$this->setHydrateClass(UpdateConnectionResponse::class);
$api = $this->getApiInstance();
$api->updateConnection('example.com', true , false);
$api->updateConnection('example.com', true, false);
}
public function testVerify()
{
$this->setRequestMethod('PUT');
@ -180,6 +177,4 @@ JSON
$api = $this->getApiInstance();
$api->verify('example.com');
}
}

View File

@ -25,24 +25,23 @@ class MessageTest extends TestCase
$this->setRequestUri('/v3/example.com/messages');
$this->setHydrateClass(SendResponse::class);
$this->setRequestBody([
'from' => 'bob@example.com',
'to' => 'sally@example.com',
'from' => 'bob@example.com',
'to' => 'sally@example.com',
'subject' => 'Test file path attachments',
'text' => 'Test',
'text' => 'Test',
'attachment' => 'resource',
]);
$api = $this->getApiInstance();
$api->send('example.com', [
'from' => 'bob@example.com',
'to' => 'sally@example.com',
'from' => 'bob@example.com',
'to' => 'sally@example.com',
'subject' => 'Test file path attachments',
'text' => 'Test',
'text' => 'Test',
'attachment' => [
['filePath'=>__DIR__.'/../TestAssets/mailgun_icon1.png', 'filename'=>'mailgun_icon1.png'],
]
['filePath' => __DIR__.'/../TestAssets/mailgun_icon1.png', 'filename' => 'mailgun_icon1.png'],
],
]);
}
public function testSendMime()
@ -104,7 +103,7 @@ class MessageTest extends TestCase
$this->setRequestMethod('GET');
$this->setRequestUri('url');
$this->setRequestHeaders([
'Accept' => 'message/rfc2822'
'Accept' => 'message/rfc2822',
]);
$this->setHydrateClass(ShowResponse::class);

View File

@ -52,7 +52,6 @@ class RouteTest extends TestCase
$api->create('catch_all()', ['forward("mailbox@myapp.com")'], 'example', 100);
}
public function testUpdate()
{
$this->setRequestMethod('PUT');

View File

@ -9,18 +9,13 @@
namespace Mailgun\Tests\Api;
use Mailgun\Api\Suppression\Bounce;
use Mailgun\Model\Suppression\Bounce\CreateResponse;
use Mailgun\Model\Suppression\Bounce\DeleteResponse;
use Mailgun\Model\Suppression\Bounce\IndexResponse;
use Mailgun\Model\Suppression\Bounce\ShowResponse;
/**
*
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class BounceTest extends TestCase
@ -52,14 +47,13 @@ class BounceTest extends TestCase
$this->setHydrateClass(CreateResponse::class);
$this->setRequestBody([
'address' => 'foo@bar.com',
'foo'=>'xxx',
'foo' => 'xxx',
]);
$api = $this->getApiInstance();
$api->create('example.com', 'foo@bar.com', ['foo'=>'xxx']);
$api->create('example.com', 'foo@bar.com', ['foo' => 'xxx']);
}
public function testDelete()
{
$this->setRequestMethod('DELETE');

View File

@ -9,18 +9,13 @@
namespace Mailgun\Tests\Api;
use Mailgun\Api\Suppression\Complaint;
use Mailgun\Model\Suppression\Complaint\CreateResponse;
use Mailgun\Model\Suppression\Complaint\DeleteResponse;
use Mailgun\Model\Suppression\Complaint\IndexResponse;
use Mailgun\Model\Suppression\Complaint\ShowResponse;
/**
*
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class ComplaintTest extends TestCase
@ -58,7 +53,6 @@ class ComplaintTest extends TestCase
$api->create('example.com', 'foo@bar.com');
}
public function testDelete()
{
$this->setRequestMethod('DELETE');

View File

@ -9,18 +9,13 @@
namespace Mailgun\Tests\Api;
use Mailgun\Api\Suppression\Unsubscribe;
use Mailgun\Model\Suppression\Unsubscribe\CreateResponse;
use Mailgun\Model\Suppression\Unsubscribe\DeleteResponse;
use Mailgun\Model\Suppression\Unsubscribe\IndexResponse;
use Mailgun\Model\Suppression\Unsubscribe\ShowResponse;
/**
*
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class UnsubscribeTest extends TestCase
@ -58,7 +53,6 @@ class UnsubscribeTest extends TestCase
$api->create('example.com', 'foo@bar.com');
}
public function testDelete()
{
$this->setRequestMethod('DELETE');

View File

@ -12,8 +12,6 @@ namespace Mailgun\Tests\Api;
use Mailgun\Api\Suppression;
/**
*
*
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class SuppressionTest extends TestCase

View File

@ -11,7 +11,6 @@ namespace Mailgun\Tests\Api;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Mailgun\Api\Webhook;
use Mailgun\Hydrator\ModelHydrator;
use Mailgun\Mailgun;
use Psr\Http\Message\ResponseInterface;
@ -145,7 +144,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
$class = $this->getApiClass();
if ($apiKey !== null) {
if (null !== $apiKey) {
return new $class($httpClient, $requestClient, $hydrator, $apiKey);
}
@ -182,7 +181,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
// Check every item in body.
foreach ($body as $item) {
if ($this->requestBody[$item['name']] === 'resource' && is_resource($item['content'])) {
if ('resource' === $this->requestBody[$item['name']] && is_resource($item['content'])) {
continue;
}
if ($this->requestBody[$item['name']] !== $item['content']) {
@ -191,7 +190,6 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
}
return true;
}
protected function getMailgunClient()

View File

@ -16,7 +16,6 @@ use Mailgun\Model\Webhook\CreateResponse;
use Mailgun\Model\Webhook\DeleteResponse;
use Mailgun\Model\Webhook\UpdateResponse;
class WebhookTest extends TestCase
{
protected function getApiClass()
@ -28,9 +27,9 @@ class WebhookTest extends TestCase
{
$api = $this->getApiInstance('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
$timestamp = '1403645220';
$token = '5egbgr1vjgqxtrnp65xfznchgdccwh5d6i09vijqi3whgowmn6';
$signature = '9cfc5c41582e51246e73c88d34db3af0a3a2692a76fbab81492842f000256d33';
$timestamp = '1403645220';
$token = '5egbgr1vjgqxtrnp65xfznchgdccwh5d6i09vijqi3whgowmn6';
$signature = '9cfc5c41582e51246e73c88d34db3af0a3a2692a76fbab81492842f000256d33';
$this->assertTrue($api->verifyWebhookSignature($timestamp, $token, $signature));
}
@ -38,9 +37,9 @@ class WebhookTest extends TestCase
public function testVerifyWebhookBad()
{
$api = $this->getApiInstance('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
$timestamp = '1403645220';
$token = 'owyldpe6nxhmrn78epljl6bj0orrki1u3d2v5e6cnlmmuox8jr';
$signature = '9cfc5c41582e51246e73c88d34db3af0a3a2692a76fbab81492842f000256d33';
$timestamp = '1403645220';
$token = 'owyldpe6nxhmrn78epljl6bj0orrki1u3d2v5e6cnlmmuox8jr';
$signature = '9cfc5c41582e51246e73c88d34db3af0a3a2692a76fbab81492842f000256d33';
$this->assertFalse($api->verifyWebhookSignature($timestamp, $token, $signature));
}
@ -79,7 +78,7 @@ class WebhookTest extends TestCase
$this->setHydrateClass(CreateResponse::class);
$this->setRequestBody([
'id' => '4711',
'url'=>'url',
'url' => 'url',
]);
$api = $this->getApiInstance('key');
@ -92,14 +91,13 @@ class WebhookTest extends TestCase
$this->setRequestUri('/v3/domains/example.com/webhooks/4711');
$this->setHydrateClass(UpdateResponse::class);
$this->setRequestBody([
'url'=>'url',
'url' => 'url',
]);
$api = $this->getApiInstance('key');
$api->update('example.com', '4711', 'url');
}
public function testDelete()
{
$this->setRequestMethod('DELETE');