mirror of
https://github.com/retailcrm/transparent-email.git
synced 2024-11-21 21:06:04 +03:00
Add Mail.ru service support
This commit is contained in:
parent
c83a423cd8
commit
df33d7edbc
23
src/Services/MailRu.php
Normal file
23
src/Services/MailRu.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace bkrukowski\TransparentEmail\Services;
|
||||
|
||||
use bkrukowski\TransparentEmail\Emails\EditableEmail;
|
||||
use bkrukowski\TransparentEmail\Emails\EmailInterface;
|
||||
|
||||
class MailRu implements ServiceInterface
|
||||
{
|
||||
public function getPrimaryEmail(EmailInterface $email) : EmailInterface
|
||||
{
|
||||
return (new EditableEmail($email))
|
||||
->removeSuffixAlias('+')
|
||||
->lowerCaseLocalPartIf(true);
|
||||
}
|
||||
|
||||
public function isSupported(EmailInterface $email) : bool
|
||||
{
|
||||
return in_array($email->getDomain(), ['mail.ru']);
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ namespace bkrukowski\TransparentEmail;
|
||||
|
||||
use bkrukowski\TransparentEmail\Services\AppsGoogleCom;
|
||||
use bkrukowski\TransparentEmail\Services\GmailCom;
|
||||
use bkrukowski\TransparentEmail\Services\MailRu;
|
||||
use bkrukowski\TransparentEmail\Services\OutlookCom;
|
||||
use bkrukowski\TransparentEmail\Services\TlenPl;
|
||||
use bkrukowski\TransparentEmail\Services\Www33MailCom;
|
||||
@ -38,6 +39,7 @@ class TransparentEmailFactory
|
||||
Www33MailCom::class,
|
||||
TlenPl::class,
|
||||
AppsGoogleCom::class,
|
||||
MailRu::class
|
||||
];
|
||||
}
|
||||
}
|
53
tests/Services/MailRuTest.php
Normal file
53
tests/Services/MailRuTest.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace bkrukowski\TransparentEmail\Tests\Services;
|
||||
|
||||
use bkrukowski\TransparentEmail\Emails\Email;
|
||||
use bkrukowski\TransparentEmail\Services\MailRu;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MailRuTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider providerGetPrimaryEmail
|
||||
*
|
||||
* @param string $inputEmail
|
||||
* @param string $outputEmail
|
||||
*/
|
||||
public function testGetPrimaryEmail(string $inputEmail, string $outputEmail)
|
||||
{
|
||||
$this->assertEquals($outputEmail, (new MailRu())->getPrimaryEmail(new Email($inputEmail)));
|
||||
}
|
||||
|
||||
public function providerGetPrimaryEmail() : array
|
||||
{
|
||||
return [
|
||||
['foobar@MAIL.RU', 'foobar@mail.ru'],
|
||||
['fOObar@MaiL.Ru', 'foobar@mail.ru'],
|
||||
['foobar+alias@mail.ru', 'foobar@mail.ru'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerIsSupported
|
||||
*
|
||||
* @param string $domain
|
||||
* @param bool $result
|
||||
*/
|
||||
public function testIsSupported(string $domain, bool $result)
|
||||
{
|
||||
$this->assertSame($result, (new MailRu())->isSupported(new Email('Jane.Doe@' . $domain)));
|
||||
}
|
||||
|
||||
public function providerIsSupported() : array
|
||||
{
|
||||
return [
|
||||
['mail.ru', true],
|
||||
['mail.RU', true],
|
||||
['MAIL.RU', true],
|
||||
['ma.il.ru', false],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user