-
-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NoRFCWarningsValidation now has an InvalidEmail instance if invalid e…
…mail is passed (#126) * NoRFCWarningsValidation now has an InvalidEmail instance if invalid email is passed * fix mentioned point
- Loading branch information
Showing
4 changed files
with
75 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Egulias\EmailValidator\Validation\Error; | ||
|
||
use Egulias\EmailValidator\Exception\InvalidEmail; | ||
|
||
class RFCWarnings extends InvalidEmail | ||
{ | ||
const CODE = 997; | ||
const REASON = 'Warnings were found.'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
Tests/EmailValidator/Validation/NoRFCWarningsValidationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Egulias\Tests\EmailValidator\Validation; | ||
|
||
use Egulias\EmailValidator\EmailLexer; | ||
use Egulias\EmailValidator\Exception\NoDomainPart; | ||
use Egulias\EmailValidator\Validation\Error\RFCWarnings; | ||
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation; | ||
|
||
class NoRFCWarningsValidationTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testInvalidEmailIsInvalid() | ||
{ | ||
$validation = new NoRFCWarningsValidation(); | ||
|
||
$this->assertFalse($validation->isValid('non-email-string', new EmailLexer())); | ||
$this->assertInstanceOf(NoDomainPart::class, $validation->getError()); | ||
} | ||
|
||
public function testEmailWithWarningsIsInvalid() | ||
{ | ||
$validation = new NoRFCWarningsValidation(); | ||
|
||
$this->assertFalse($validation->isValid(str_repeat('x', 254).'@example.com', new EmailLexer())); // too long email | ||
$this->assertInstanceOf(RFCWarnings::class, $validation->getError()); | ||
} | ||
|
||
public function testEmailWithoutWarningsIsValid() | ||
{ | ||
$validation = new NoRFCWarningsValidation(); | ||
|
||
$this->assertTrue($validation->isValid('[email protected]', new EmailLexer())); | ||
$this->assertNull($validation->getError()); | ||
} | ||
} |
23 changes: 0 additions & 23 deletions
23
Tests/EmailValidator/Validation/NoWarningsRFCValidationTest.php
This file was deleted.
Oops, something went wrong.