mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-22 12:36:02 +03:00
Added tests for our models
This commit is contained in:
parent
2337184f85
commit
17eafbf9c9
10
tests/Model/BaseModelTest.php
Normal file
10
tests/Model/BaseModelTest.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailgun\Tests\Model;
|
||||
|
||||
class BaseModelTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
}
|
27
tests/Model/Domain/ConnectionResponseTest.php
Normal file
27
tests/Model/Domain/ConnectionResponseTest.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\ConnectionResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class ConnectionResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<JSON
|
||||
{
|
||||
"connection": {
|
||||
"require_tls": false,
|
||||
"skip_verification": false
|
||||
}
|
||||
}
|
||||
JSON;
|
||||
$model = ConnectionResponse::create(json_decode($json, true));
|
||||
$this->assertFalse($model->getRequireTLS());
|
||||
$this->assertFalse($model->getSkipVerification());
|
||||
}
|
||||
}
|
24
tests/Model/Domain/CreateCredentialResponseTest.php
Normal file
24
tests/Model/Domain/CreateCredentialResponseTest.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\ConnectionResponse;
|
||||
use Mailgun\Model\Domain\CreateCredentialResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class CreateCredentialResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<JSON
|
||||
{
|
||||
"message": "Created 1 credentials pair(s)"
|
||||
}
|
||||
JSON;
|
||||
$model = CreateCredentialResponse::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getMessage());
|
||||
}
|
||||
}
|
73
tests/Model/Domain/CreateResponseTest.php
Normal file
73
tests/Model/Domain/CreateResponseTest.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\ConnectionResponse;
|
||||
use Mailgun\Model\Domain\CreateCredentialResponse;
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\CredentialResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class CreateResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<JSON
|
||||
{
|
||||
"domain": {
|
||||
"name": "example.com",
|
||||
"created_at": "Fri, 22 Nov 2013 18:42:33 GMT",
|
||||
"wildcard": false,
|
||||
"spam_action": "disabled",
|
||||
"smtp_login": "postmaster@example.com",
|
||||
"smtp_password": "thiswontwork",
|
||||
"state": "active"
|
||||
},
|
||||
"receiving_dns_records": [
|
||||
{
|
||||
"priority": "10",
|
||||
"record_type": "MX",
|
||||
"valid": "valid",
|
||||
"value": "mxa.mailgun.org"
|
||||
},
|
||||
{
|
||||
"priority": "10",
|
||||
"record_type": "MX",
|
||||
"valid": "valid",
|
||||
"value": "mxb.mailgun.org"
|
||||
}
|
||||
],
|
||||
"message": "Domain has been created",
|
||||
"sending_dns_records": [
|
||||
{
|
||||
"record_type": "TXT",
|
||||
"valid": "valid",
|
||||
"name": "example.com",
|
||||
"value": "v=spf1 include:mailgun.org ~all"
|
||||
},
|
||||
{
|
||||
"record_type": "TXT",
|
||||
"valid": "valid",
|
||||
"name": "k1._domainkey.example.com",
|
||||
"value": "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4G...."
|
||||
},
|
||||
{
|
||||
"record_type": "CNAME",
|
||||
"valid": "valid",
|
||||
"name": "email.example.com",
|
||||
"value": "mailgun.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
JSON;
|
||||
$model = CreateResponse::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getMessage());
|
||||
$this->assertNotEmpty($model->getDomain());
|
||||
$this->assertNotEmpty($model->getInboundDNSRecords());
|
||||
$this->assertNotEmpty($model->getOutboundDNSRecords());
|
||||
}
|
||||
}
|
32
tests/Model/Domain/CredentialResponseItemTest.php
Normal file
32
tests/Model/Domain/CredentialResponseItemTest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\ConnectionResponse;
|
||||
use Mailgun\Model\Domain\CreateCredentialResponse;
|
||||
use Mailgun\Model\Domain\CredentialResponse;
|
||||
use Mailgun\Model\Domain\CredentialResponseItem;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class CredentialResponseItemTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<JSON
|
||||
{
|
||||
"size_bytes": 5,
|
||||
"created_at": "Tue, 27 Sep 2011 20:24:22 GMT",
|
||||
"mailbox": "user@samples.mailgun.org",
|
||||
"login": "user"
|
||||
}
|
||||
JSON;
|
||||
$model = CredentialResponseItem::create(json_decode($json, true));
|
||||
$this->assertEquals('user', $model->getLogin());
|
||||
$this->assertEquals('user@samples.mailgun.org', $model->getMailbox());
|
||||
$this->assertEquals('5', $model->getSizeBytes());
|
||||
$this->assertEquals(new \DateTime('Tue, 27 Sep 2011 20:24:22 GMT'), $model->getCreatedAt());
|
||||
}
|
||||
}
|
41
tests/Model/Domain/CredentialResponseTest.php
Normal file
41
tests/Model/Domain/CredentialResponseTest.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\ConnectionResponse;
|
||||
use Mailgun\Model\Domain\CreateCredentialResponse;
|
||||
use Mailgun\Model\Domain\CredentialResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class CredentialResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<JSON
|
||||
{
|
||||
"total_count": 2,
|
||||
"items": [
|
||||
{
|
||||
"size_bytes": 5,
|
||||
"created_at": "Tue, 27 Sep 2011 20:24:22 GMT",
|
||||
"mailbox": "user@samples.mailgun.org",
|
||||
"login": "user"
|
||||
},
|
||||
{
|
||||
"size_bytes": 0,
|
||||
"created_at": "Thu, 06 Oct 2011 10:22:36 GMT",
|
||||
"mailbox": "user@samples.mailgun.org",
|
||||
"login": "user@samples.mailgun.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON;
|
||||
$model = CredentialResponse::create(json_decode($json, true));
|
||||
$this->assertEquals(2, $model->getTotalCount());
|
||||
$this->assertCount(2, $model->getCredentials());
|
||||
|
||||
}
|
||||
}
|
@ -10,9 +10,10 @@
|
||||
namespace Mailgun\Tests\Model\Suppression\Unsubscribe;
|
||||
|
||||
use Mailgun\Model\Suppression\Unsubscribe\Unsubscribe;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
class UnsubscribeTest extends PHPUnit_Framework_TestCase
|
||||
class UnsubscribeTest extends BaseModelTest
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
|
Loading…
Reference in New Issue
Block a user