mirror of
https://github.com/egulias/EmailValidator.git
synced 2026-08-21 16:53:36 +00:00
8e526a57c1
* scafolding for MessageID validation * Improve domain valid tokens * Improved EmailParser to remove leaked logic. User of lexer recorder within parsers. * MessageIDParser passing tests. * change left for right, which is the right one * psaml errors * Better naming * comments are not allowed in IDLeft for message-id * Suppress psalm inheritance over tokens and dependencies * Update src/Parser.php Co-authored-by: Alexander M. Turek <me@derrabus.de> * Update src/Parser.php Co-authored-by: Alexander M. Turek <me@derrabus.de> * improve parser from comments Co-authored-by: Alexander M. Turek <me@derrabus.de>
71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?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 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 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");
|
|
|
|
}
|
|
}
|