2019-01-12 11:54:00 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-01-12 12:09:22 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Mailgun
|
|
|
|
*
|
|
|
|
* This software may be modified and distributed under the terms
|
|
|
|
* of the MIT license. See the LICENSE file for details.
|
|
|
|
*/
|
|
|
|
|
2019-01-12 11:54:00 +03:00
|
|
|
namespace Mailgun\Tests\Model\EmailValidation;
|
|
|
|
|
|
|
|
use Mailgun\Model\EmailValidation\ValidateResponse;
|
|
|
|
use Mailgun\Tests\Model\BaseModelTest;
|
|
|
|
|
|
|
|
class ValidateResponseTest extends BaseModelTest
|
|
|
|
{
|
|
|
|
public function testCreate()
|
|
|
|
{
|
|
|
|
$json =
|
|
|
|
<<<'JSON'
|
|
|
|
{
|
|
|
|
"address": "foo@mailgun.net",
|
|
|
|
"is_disposable_address": false,
|
|
|
|
"is_role_address": true,
|
2019-08-10 01:57:04 +03:00
|
|
|
"reason": [],
|
|
|
|
"result": "deliverable",
|
|
|
|
"risk": "low"
|
2019-01-12 11:54:00 +03:00
|
|
|
}
|
|
|
|
JSON;
|
|
|
|
$model = ValidateResponse::create(json_decode($json, true));
|
|
|
|
$this->assertTrue($model->isMailboxVerification());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testEmailValidation()
|
|
|
|
{
|
|
|
|
$data = [
|
|
|
|
'address' => 'foo@mailgun.net',
|
|
|
|
'is_disposable_address' => false,
|
|
|
|
'is_role_address' => false,
|
2019-08-10 01:57:04 +03:00
|
|
|
'reason' => [],
|
|
|
|
'result' => 'deliverable',
|
2019-08-10 01:59:30 +03:00
|
|
|
'risk' => 'low',
|
2019-01-12 11:54:00 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
$parts = ValidateResponse::create($data);
|
|
|
|
|
|
|
|
$this->assertEquals($data['address'], $parts->getAddress());
|
|
|
|
$this->assertEquals($data['is_disposable_address'], $parts->isDisposableAddress());
|
|
|
|
$this->assertEquals($data['is_role_address'], $parts->isRoleAddress());
|
|
|
|
$this->assertEquals($data['reason'], $parts->getReason());
|
2019-08-10 01:57:04 +03:00
|
|
|
$this->assertEquals($data['result'], $parts->getResult());
|
|
|
|
$this->assertEquals($data['risk'], $parts->getRisk());
|
2019-01-12 11:54:00 +03:00
|
|
|
}
|
|
|
|
}
|