71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace KupShop\KupShopBundle\Tests;
|
|
|
|
use KupShop\KupShopBundle\Util\Mail\EmailCheck;
|
|
use KupShop\KupShopBundle\Util\StringUtil;
|
|
|
|
class MailCheckTest extends \DatabaseTestCase
|
|
{
|
|
/** @var EmailCheck */
|
|
private $mailCheck;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->mailCheck = $this->get(EmailCheck::class);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider data_normalize
|
|
*/
|
|
public function testNormalizeEmail($actual, $expected)
|
|
{
|
|
$this->assertEquals($expected, StringUtil::normalize($actual));
|
|
}
|
|
|
|
public function data_normalize()
|
|
{
|
|
return [
|
|
['ondřej@testík.cz', 'ondrej@testik.cz'],
|
|
['žluťoučký@kůň.cz', 'zlutoucky@kun.cz'],
|
|
['žlutý-kůň@čt.cz', 'zluty-kun@ct.cz'],
|
|
['žlutý_kůň@čt.cz', 'zluty_kun@ct.cz'],
|
|
['mail@wpj.cz', 'mail@wpj.cz'],
|
|
['disposable.style.email.with+symbol@example.com', 'disposable.style.email.with+symbol@example.com'],
|
|
['user.name+tag+sorting@example.com', 'user.name+tag+sorting@example.com'],
|
|
['example-indeed@strange-example.com', 'example-indeed@strange-example.com'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider data_emails
|
|
*/
|
|
public function testEmailDomainIsValid($email, $valid)
|
|
{
|
|
$this->assertEquals($valid, $this->mailCheck->isEmailDomainValid($email));
|
|
}
|
|
|
|
public function data_emails()
|
|
{
|
|
return [
|
|
['test@sazka.cz', true],
|
|
['test', false],
|
|
['test@google.cz', true],
|
|
['test@google.com', true],
|
|
['test@seznam.cz', true],
|
|
['test@lkfjdf.cz', false],
|
|
['benes@wpj.cz', true],
|
|
['ddd@wpjjsoulooseri.com', false],
|
|
'disposable.style.email.with+symbol@google.com' => ['disposable.style.email.with+symbol@google.com', true],
|
|
['test test@gmail.com', false],
|
|
['test_test@gmail.com', true],
|
|
['test-test@gmail.com', true],
|
|
['test+test@gmail.com', true],
|
|
['žluťoučký@kůň.cz', false],
|
|
['žluťoučký@wpj.cz', false],
|
|
];
|
|
}
|
|
}
|