1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
<?php
namespace Egulias\EmailValidator\Tests\EmailValidator\Validation;
use Egulias\EmailValidator\EmailLexer;
use Egulias\EmailValidator\Validation\MessageIDValidation;
use PHPUnit\Framework\TestCase;
class MessageIDValidationTest extends TestCase
{
/**
* @dataProvider validMessageIDs
*/
public function testValidMessageIDs(string $messageID)
{
$validator = new MessageIDValidation();
$this->assertTrue($validator->isValid($messageID, new EmailLexer()));
}
public static function validMessageIDs() : array
{
return [
['a@b.c+&%$.d'],
['a.b+&%$.c@d'],
['a@รค'],
];
}
/**
* @dataProvider invalidMessageIDs
*/
public function testInvalidMessageIDs(string $messageID)
{
$validator = new MessageIDValidation();
$this->assertFalse($validator->isValid($messageID, new EmailLexer()));
}
public static function invalidMessageIDs() : array
{
return [
['example'],
['example@with space'],
['example@iana.'],
['example@ia\na.'],
/**
* RFC 2822, section 3.6.4, Page 25
* Since the msg-id has
* a similar syntax to angle-addr (identical except that comments and
* folding white space are not allowed), a good method is to put the
* domain name (or a domain literal IP address) of the host on which the
* message identifier was created on the right hand side of the "@", and
* put a combination of the current absolute date and time along with
* some other currently unique (perhaps sequential) identifier available
* on the system (for example, a process id number) on the left hand
* side.
*/
['example(comment)@example.com'],
["\r\nFWS@example.com"]
];
}
public function testInvalidMessageIDsWithError()
{
$this->markTestIncomplete("missing error check");
}
}
|