2016-09-24 13:09:20 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace bkrukowski\TransparentEmail\Tests\Emails;
|
|
|
|
|
|
|
|
use bkrukowski\TransparentEmail\Emails\Email;
|
|
|
|
use bkrukowski\TransparentEmail\Emails\InvalidEmailException;
|
2020-02-13 16:27:05 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-09-24 13:09:20 +03:00
|
|
|
|
2020-02-13 16:27:05 +03:00
|
|
|
class EmailTest extends TestCase
|
2016-09-24 13:09:20 +03:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider providerConstructor
|
|
|
|
*
|
|
|
|
* @param string $email
|
|
|
|
* @param bool $expectedException
|
|
|
|
* @param string $localPart
|
|
|
|
* @param string $domain
|
|
|
|
* @param bool $caseSensitive
|
|
|
|
*/
|
|
|
|
public function testConstructor(
|
|
|
|
string $email,
|
|
|
|
bool $expectedException,
|
|
|
|
string $localPart = '',
|
|
|
|
string $domain = '',
|
|
|
|
bool $caseSensitive = false
|
|
|
|
) {
|
|
|
|
if ($expectedException) {
|
|
|
|
$this->expectException(InvalidEmailException::class);
|
|
|
|
}
|
|
|
|
$object = new Email($email, $caseSensitive);
|
|
|
|
$this->assertSame($localPart, $object->getLocalPart());
|
|
|
|
$this->assertSame($domain, $object->getDomain());
|
|
|
|
}
|
|
|
|
|
2016-10-14 21:25:52 +03:00
|
|
|
public function providerConstructor() : array
|
2016-09-24 13:09:20 +03:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
['john doe@example.com', true],
|
|
|
|
['.johndoe@example.com', true],
|
|
|
|
['Jane.Doe@Example.COM', false, 'Jane.Doe', 'example.com', true],
|
|
|
|
['Jane.Doe@Example.COM', false, 'jane.doe', 'example.com'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|