2018-02-02 02:25:14 +03:00
|
|
|
<?php
|
|
|
|
|
2019-01-12 11:54:00 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2018-02-02 02:25:14 +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\Api;
|
|
|
|
|
2018-02-02 02:36:44 +03:00
|
|
|
use GuzzleHttp\Psr7\Response;
|
2018-02-02 02:25:14 +03:00
|
|
|
use Mailgun\Api\EmailValidation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author David Garcia <me@davidgarcia.cat>
|
|
|
|
*/
|
|
|
|
class EmailValidationTest extends TestCase
|
|
|
|
{
|
|
|
|
protected function getApiClass()
|
|
|
|
{
|
|
|
|
return EmailValidation::class;
|
|
|
|
}
|
2018-02-02 02:36:44 +03:00
|
|
|
|
|
|
|
public function testValidEmail()
|
|
|
|
{
|
2019-08-10 01:56:36 +03:00
|
|
|
$params = ['address' => 'foo@mailgun.net'];
|
2018-02-02 02:36:44 +03:00
|
|
|
|
|
|
|
$api = $this->getApiMock();
|
|
|
|
|
|
|
|
$api->expects($this->once())
|
|
|
|
->method('httpGet')
|
2019-08-10 01:04:04 +03:00
|
|
|
->with('/v4/address/validate', $params)
|
2018-02-02 02:36:44 +03:00
|
|
|
->willReturn(new Response());
|
|
|
|
|
|
|
|
$api->validate($params['address'], $params['mailbox_verification']);
|
|
|
|
}
|
2018-02-02 02:42:11 +03:00
|
|
|
|
|
|
|
public function testParseEmail()
|
|
|
|
{
|
|
|
|
$params = [
|
|
|
|
'addresses' => 'me@davidgarcia.cat',
|
|
|
|
'syntax_only' => true,
|
|
|
|
];
|
|
|
|
|
|
|
|
$api = $this->getApiMock();
|
|
|
|
|
|
|
|
$api->expects($this->once())
|
|
|
|
->method('httpGet')
|
|
|
|
->with('/address/private/parse', $params)
|
|
|
|
->willReturn(new Response());
|
|
|
|
|
|
|
|
$api->parse($params['addresses'], $params['syntax_only']);
|
|
|
|
}
|
2018-02-02 02:25:14 +03:00
|
|
|
}
|