2020-02-13 13:00:21 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace bkrukowski\TransparentEmail\Tests\Services;
|
|
|
|
|
|
|
|
use bkrukowski\TransparentEmail\Emails\Email;
|
2020-02-17 17:00:23 +03:00
|
|
|
use bkrukowski\TransparentEmail\Services\MailRu;
|
2020-02-13 16:27:05 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2020-02-13 13:00:21 +03:00
|
|
|
|
2020-02-17 17:00:23 +03:00
|
|
|
class MailRuTest extends TestCase
|
2020-02-13 13:00:21 +03:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider providerGetPrimaryEmail
|
|
|
|
*
|
|
|
|
* @param string $inputEmail
|
|
|
|
* @param string $outputEmail
|
2022-05-05 15:52:56 +03:00
|
|
|
* @param bool $cyrillicAllowed
|
2020-02-13 13:00:21 +03:00
|
|
|
*/
|
2022-05-05 15:52:56 +03:00
|
|
|
public function testGetPrimaryEmail(string $inputEmail, string $outputEmail, bool $cyrillicAllowed = false)
|
2020-02-13 13:00:21 +03:00
|
|
|
{
|
2022-05-05 15:52:56 +03:00
|
|
|
$this->assertEquals($outputEmail, (new MailRu())->getPrimaryEmail(new Email($inputEmail, false, $cyrillicAllowed)));
|
2020-02-13 13:00:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function providerGetPrimaryEmail() : array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['foobar@MAIL.RU', 'foobar@mail.ru'],
|
|
|
|
['fOObar@MaiL.Ru', 'foobar@mail.ru'],
|
|
|
|
['foobar+alias@mail.ru', 'foobar@mail.ru'],
|
2022-05-05 15:52:56 +03:00
|
|
|
// Cyrillic use
|
|
|
|
['иванов@MAIL.RU', 'иванов@mail.ru', true],
|
|
|
|
['иванОВ@MaiL.Ru', 'иванов@mail.ru', true],
|
|
|
|
['иванов+alias@mail.ru', 'иванов@mail.ru', true],
|
2020-02-13 13:00:21 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providerIsSupported
|
|
|
|
*
|
|
|
|
* @param string $domain
|
|
|
|
* @param bool $result
|
|
|
|
*/
|
|
|
|
public function testIsSupported(string $domain, bool $result)
|
|
|
|
{
|
2020-02-17 17:00:23 +03:00
|
|
|
$this->assertSame($result, (new MailRu())->isSupported(new Email('Jane.Doe@' . $domain)));
|
2020-02-13 13:00:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function providerIsSupported() : array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
['mail.ru', true],
|
|
|
|
['mail.RU', true],
|
|
|
|
['MAIL.RU', true],
|
|
|
|
['ma.il.ru', false],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|