From aa0eeae92bf53ad69be165a413c661d26aae7952 Mon Sep 17 00:00:00 2001 From: Eduardo Gulias Davis Date: Sun, 3 May 2020 15:25:33 +0200 Subject: [PATCH] local part comments --- EmailValidator/Parser/LocalPart.php | 4 ++-- .../Result/Reason/UnOpenedComment.php | 16 ++++++++++++++++ Tests/EmailValidator/LexerTokensTest.php | 2 +- .../Validation/RFCValidationTest.php | 18 +++++++++--------- .../Validation/ValitadionTest.php | 2 +- 5 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 EmailValidator/Result/Reason/UnOpenedComment.php diff --git a/EmailValidator/Parser/LocalPart.php b/EmailValidator/Parser/LocalPart.php index 7776447..99f07a4 100644 --- a/EmailValidator/Parser/LocalPart.php +++ b/EmailValidator/Parser/LocalPart.php @@ -10,7 +10,7 @@ use Egulias\EmailValidator\Result\InvalidEmail; use Egulias\EmailValidator\Warning\LocalTooLong; use Egulias\EmailValidator\Exception\ExpectingATEXT; use Egulias\EmailValidator\Result\Reason\DotAtStart; -use Egulias\EmailValidator\Exception\UnopenedComment; +use Egulias\EmailValidator\Result\Reason\UnOpenedComment; class LocalPart extends Parser { @@ -43,7 +43,7 @@ class LocalPart extends Parser if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) { if ($openedParenthesis === 0) { - throw new UnopenedComment(); + return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']); } $openedParenthesis--; diff --git a/EmailValidator/Result/Reason/UnOpenedComment.php b/EmailValidator/Result/Reason/UnOpenedComment.php new file mode 100644 index 0000000..cc7915c --- /dev/null +++ b/EmailValidator/Result/Reason/UnOpenedComment.php @@ -0,0 +1,16 @@ +fail("implement"); + $this->markTestIncomplete("implement"); } } \ No newline at end of file diff --git a/Tests/EmailValidator/Validation/RFCValidationTest.php b/Tests/EmailValidator/Validation/RFCValidationTest.php index e6b66c6..5b22d92 100644 --- a/Tests/EmailValidator/Validation/RFCValidationTest.php +++ b/Tests/EmailValidator/Validation/RFCValidationTest.php @@ -35,12 +35,12 @@ use Egulias\EmailValidator\Exception\ExpectingATEXT; use Egulias\EmailValidator\Exception\ExpectingDTEXT; use Egulias\EmailValidator\Validation\RFCValidation; use Egulias\EmailValidator\Exception\UnclosedComment; -use Egulias\EmailValidator\Exception\UnopenedComment; +use Egulias\EmailValidator\Exception\UnopenedComment as ExceptionUnopenedComment; use Egulias\EmailValidator\Result\Reason\NoLocalPart; -use Egulias\EmailValidator\Exception\UnclosedQuotedString; +use Egulias\EmailValidator\Result\Reason\UnOpenedComment; use Egulias\EmailValidator\Result\Reason\DotAtStart as ReasonDotAtStart; use Egulias\EmailValidator\Result\Reason\ExpectingATEXT as ReasonExpectingATEXT; -use Egulias\EmailValidator\Result\Reason\UnclosedQuotedString as ReasonUnclosedQuotedString; +use Egulias\EmailValidator\Result\Reason\UnclosedQuotedString; class RFCValidationTest extends TestCase { @@ -200,7 +200,7 @@ class RFCValidationTest extends TestCase [new DotAtEnd(), 'example@localhost.'], [new DotAtEnd(), 'example.@example.co.uk'], [new UnclosedComment(), '(example@localhost'], - [new InvalidEmail(new ReasonUnclosedQuotedString(), '"'), '"example@localhost'], + [new InvalidEmail(new UnclosedQuotedString(), '"'), '"example@localhost'], [ new InvalidEmail( new ReasonExpectingATEXT('https://tools.ietf.org/html/rfc5322#section-3.2.4 - quoted string should be a unit'), @@ -208,11 +208,11 @@ class RFCValidationTest extends TestCase 'exa"mple@localhost' ], [new UnclosedComment(), '(example@localhost'], - [new UnopenedComment(), 'comment)example@localhost'], - [new UnopenedComment(), 'example(comment))@localhost'], - [new UnopenedComment(), 'example@comment)localhost'], - [new UnopenedComment(), 'example@localhost(comment))'], - [new UnopenedComment(), 'example@(comment))example.com'], + [new InvalidEmail(new UnOpenedComment(), ')'), 'comment)example@localhost'], + [new InvalidEmail(new UnOpenedComment(), ')'), 'example(comment))@localhost'], + [new ExceptionUnopenedComment, 'example@comment)localhost'], + [new ExceptionUnopenedComment, 'example@localhost(comment))'], + [new ExceptionUnopenedComment, 'example@(comment))example.com'], //This was the original. But atext is not allowed after \n //array(EmailValidator::ERR_EXPECTING_ATEXT, "exampl\ne@example.co.uk"), [new AtextAfterCFWS(), "exampl\ne@example.co.uk"], diff --git a/Tests/EmailValidator/Validation/ValitadionTest.php b/Tests/EmailValidator/Validation/ValitadionTest.php index a811741..fedaf62 100644 --- a/Tests/EmailValidator/Validation/ValitadionTest.php +++ b/Tests/EmailValidator/Validation/ValitadionTest.php @@ -8,6 +8,6 @@ class ValidationTest extends TestCase { public function testValidationReturnsResult() { - $this->fail("implement return type Validation"); + $this->markTestIncomplete("implement return type Validation"); } }