mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-25 14:26:04 +03:00
Added more tests
This commit is contained in:
parent
61c0f32dfb
commit
0145ddd481
35
tests/Model/Domain/DeleteCredentialResponseTest.php
Normal file
35
tests/Model/Domain/DeleteCredentialResponseTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class DeleteCredentialResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"message": "Credentials have been deleted",
|
||||
"spec": "alice@samples.mailgun.org"
|
||||
}
|
||||
|
||||
JSON;
|
||||
$model = DeleteCredentialResponse::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getMessage());
|
||||
$this->assertEmpty($model->getError());
|
||||
$this->assertNotEmpty($model->getSpec());
|
||||
}
|
||||
}
|
32
tests/Model/Domain/DeleteResponseTest.php
Normal file
32
tests/Model/Domain/DeleteResponseTest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class DeleteResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"message": "Domain has been deleted"
|
||||
}
|
||||
JSON;
|
||||
$model = DeleteResponse::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getMessage());
|
||||
}
|
||||
}
|
40
tests/Model/Domain/DnsRecordTest.php
Normal file
40
tests/Model/Domain/DnsRecordTest.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Model\Domain\DnsRecord;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class DnsRecordTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"record_type": "TXT",
|
||||
"valid": "valid",
|
||||
"name": "example.com",
|
||||
"value": "v=spf1 include:mailgun.org ~all"
|
||||
}
|
||||
JSON;
|
||||
$model = DnsRecord::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getType());
|
||||
$this->assertNotEmpty($model->getValidity());
|
||||
$this->assertTrue($model->isValid());
|
||||
$this->assertNotEmpty($model->getName());
|
||||
$this->assertNotEmpty($model->getValue());
|
||||
}
|
||||
}
|
46
tests/Model/Domain/DomainTest.php
Normal file
46
tests/Model/Domain/DomainTest.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Model\Domain\DnsRecord;
|
||||
use Mailgun\Model\Domain\Domain;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class DomainTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"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"
|
||||
}
|
||||
JSON;
|
||||
$model = Domain::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getName());
|
||||
$this->assertNotEmpty($model->getCreatedAt());
|
||||
$this->assertFalse($model->isWildcard());
|
||||
$this->assertNotEmpty($model->getSpamAction());
|
||||
$this->assertNotEmpty($model->getSmtpPassword());
|
||||
$this->assertNotEmpty($model->getSmtpUsername());
|
||||
$this->assertNotEmpty($model->getState());
|
||||
}
|
||||
}
|
48
tests/Model/Domain/IndexResponseTest.php
Normal file
48
tests/Model/Domain/IndexResponseTest.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Model\Domain\DnsRecord;
|
||||
use Mailgun\Model\Domain\Domain;
|
||||
use Mailgun\Model\Domain\IndexResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class IndexResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"total_count": 1,
|
||||
"items": [
|
||||
{
|
||||
"created_at": "Wed, 10 Jul 2013 19:26:52 GMT",
|
||||
"smtp_login": "postmaster@samples.mailgun.org",
|
||||
"name": "samples.mailgun.org",
|
||||
"smtp_password": "4rtqo4p6rrx9",
|
||||
"wildcard": true,
|
||||
"spam_action": "disabled",
|
||||
"state": "active"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
JSON;
|
||||
$model = IndexResponse::create(json_decode($json, true));
|
||||
$this->assertEquals(1, $model->getTotalCount());
|
||||
$this->assertCount(1, $model->getDomains());
|
||||
}
|
||||
}
|
80
tests/Model/Domain/ShowResponseTest.php
Normal file
80
tests/Model/Domain/ShowResponseTest.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Model\Domain\DnsRecord;
|
||||
use Mailgun\Model\Domain\Domain;
|
||||
use Mailgun\Model\Domain\IndexResponse;
|
||||
use Mailgun\Model\Domain\ShowResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class ShowResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"domain": {
|
||||
"created_at": "Wed, 10 Jul 2013 19:26:52 GMT",
|
||||
"smtp_login": "postmaster@domain.com",
|
||||
"name": "domain.com",
|
||||
"smtp_password": "4rtqo4p6rrx9",
|
||||
"wildcard": false,
|
||||
"spam_action": "tag",
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"sending_dns_records": [
|
||||
{
|
||||
"record_type": "TXT",
|
||||
"valid": "valid",
|
||||
"name": "domain.com",
|
||||
"value": "v=spf1 include:mailgun.org ~all"
|
||||
},
|
||||
{
|
||||
"record_type": "TXT",
|
||||
"valid": "valid",
|
||||
"name": "domain.com",
|
||||
"value": "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUA...."
|
||||
},
|
||||
{
|
||||
"record_type": "CNAME",
|
||||
"valid": "valid",
|
||||
"name": "email.domain.com",
|
||||
"value": "mailgun.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON;
|
||||
$model = ShowResponse::create(json_decode($json, true));
|
||||
$this->assertCount(2, $model->getInboundDNSRecords());
|
||||
$this->assertCount(3, $model->getOutboundDNSRecords());
|
||||
$this->assertInstanceOf(Domain::class, $model->getDomain());
|
||||
}
|
||||
}
|
41
tests/Model/Domain/UpdateConnectionResponseTest.php
Normal file
41
tests/Model/Domain/UpdateConnectionResponseTest.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Model\Domain\DnsRecord;
|
||||
use Mailgun\Model\Domain\Domain;
|
||||
use Mailgun\Model\Domain\IndexResponse;
|
||||
use Mailgun\Model\Domain\ShowResponse;
|
||||
use Mailgun\Model\Domain\UpdateConnectionResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class UpdateConnectionResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"message": "Domain connection settings have been updated, may take 10 minutes to fully propagate",
|
||||
"require-tls": true,
|
||||
"skip-verification": false
|
||||
}
|
||||
JSON;
|
||||
$model = UpdateConnectionResponse::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getMessage());
|
||||
$this->assertTrue($model->getRequireTLS());
|
||||
$this->assertFalse($model->getSkipVerification());
|
||||
}
|
||||
}
|
38
tests/Model/Domain/UpdateCredentialResponseTest.php
Normal file
38
tests/Model/Domain/UpdateCredentialResponseTest.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Model\Domain\DnsRecord;
|
||||
use Mailgun\Model\Domain\Domain;
|
||||
use Mailgun\Model\Domain\IndexResponse;
|
||||
use Mailgun\Model\Domain\ShowResponse;
|
||||
use Mailgun\Model\Domain\UpdateConnectionResponse;
|
||||
use Mailgun\Model\Domain\UpdateCredentialResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class UpdateCredentialResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"message": "Password changed"
|
||||
}
|
||||
JSON;
|
||||
$model = UpdateCredentialResponse::create(json_decode($json, true));
|
||||
$this->assertNotEmpty($model->getMessage());
|
||||
}
|
||||
}
|
81
tests/Model/Domain/VerifyResponseTest.php
Normal file
81
tests/Model/Domain/VerifyResponseTest.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Mailgun
|
||||
*
|
||||
* This software may be modified and distributed under the terms
|
||||
* of the MIT license. See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
namespace Mailgun\Tests\Model\Domain;
|
||||
|
||||
use Mailgun\Model\Domain\CreateResponse;
|
||||
use Mailgun\Model\Domain\DeleteCredentialResponse;
|
||||
use Mailgun\Model\Domain\DeleteResponse;
|
||||
use Mailgun\Model\Domain\DnsRecord;
|
||||
use Mailgun\Model\Domain\Domain;
|
||||
use Mailgun\Model\Domain\IndexResponse;
|
||||
use Mailgun\Model\Domain\ShowResponse;
|
||||
use Mailgun\Model\Domain\UpdateConnectionResponse;
|
||||
use Mailgun\Model\Domain\UpdateCredentialResponse;
|
||||
use Mailgun\Model\Domain\VerifyResponse;
|
||||
use Mailgun\Tests\Model\BaseModelTest;
|
||||
|
||||
class VerifyResponseTest extends BaseModelTest
|
||||
{
|
||||
public function testCreate()
|
||||
{
|
||||
$json =
|
||||
<<<'JSON'
|
||||
{
|
||||
"domain": {
|
||||
"created_at": "Wed, 10 Jul 2013 19:26:52 GMT",
|
||||
"smtp_login": "postmaster@domain.com",
|
||||
"name": "domain.com",
|
||||
"smtp_password": "4rtqo4p6rrx9",
|
||||
"wildcard": false,
|
||||
"spam_action": "tag",
|
||||
"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"
|
||||
}
|
||||
],
|
||||
"sending_dns_records": [
|
||||
{
|
||||
"record_type": "TXT",
|
||||
"valid": "valid",
|
||||
"name": "domain.com",
|
||||
"value": "v=spf1 include:mailgun.org ~all"
|
||||
},
|
||||
{
|
||||
"record_type": "TXT",
|
||||
"valid": "valid",
|
||||
"name": "domain.com",
|
||||
"value": "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUA...."
|
||||
},
|
||||
{
|
||||
"record_type": "CNAME",
|
||||
"valid": "valid",
|
||||
"name": "email.domain.com",
|
||||
"value": "mailgun.org"
|
||||
}
|
||||
]
|
||||
}
|
||||
JSON;
|
||||
$model = VerifyResponse::create(json_decode($json, true));
|
||||
$this->assertNull($model->getMessage());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user