mailgun-php/tests/Model/EmailValidation/ParseResponseTest.php

64 lines
1.5 KiB
PHP
Raw Permalink Normal View History

<?php
declare(strict_types=1);
2018-02-02 02:54:22 +03:00
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.
*/
namespace Mailgun\Tests\Model\EmailValidation;
use Mailgun\Model\EmailValidation\ParseResponse;
use Mailgun\Tests\Model\BaseModelTest;
class ParseResponseTest extends BaseModelTest
{
public function testCreate()
{
$json =
<<<'JSON'
{
"parsed": [
"Alice <alice@example.com>",
"bob@example.com"
],
"unparseable": [
]
}
JSON;
$model = ParseResponse::create(json_decode($json, true));
$this->assertNotEmpty($model->getParsed());
$this->assertCount(2, $model->getParsed());
$this->assertEmpty($model->getUnparseable());
}
public function testParseConstructorWithValidData()
{
$data = [
'parsed' => ['parsed data'],
'unparseable' => ['unparseable data'],
];
$parts = ParseResponse::create($data);
$this->assertEquals($data['parsed'], $parts->getParsed());
$this->assertEquals($data['unparseable'], $parts->getUnparseable());
}
public function testParseConstructorWithInvalidData()
{
$data = [
'parsed' => null,
'unparseable' => null,
];
$parts = ParseResponse::create($data);
$this->assertEquals([], $parts->getParsed());
$this->assertEquals([], $parts->getUnparseable());
}
}