-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MultipleValidatorWithAnd now can break out of loop when error occurs (#…
…122) * MultipleValidatorWithAnd now can break out of loop when error occurs * improved logic * updated doc * bugfix
- Loading branch information
Showing
2 changed files
with
78 additions
and
3 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
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 |
---|---|---|
|
@@ -25,7 +25,7 @@ public function testUsesAndLogicalOperation() | |
} | ||
|
||
/** | ||
* @expectedException Egulias\EmailValidator\Validation\Exception\EmptyValidationList | ||
* @expectedException \Egulias\EmailValidator\Validation\Exception\EmptyValidationList | ||
*/ | ||
public function testEmptyListIsNotAllowed() | ||
{ | ||
|
@@ -79,4 +79,27 @@ public function testGathersAllTheErrors() | |
$multipleValidation->isValid("[email protected]", $lexer); | ||
$this->assertEquals($expectedResult, $multipleValidation->getError()); | ||
} | ||
|
||
public function testBreakOutOfLoopWhenError() | ||
{ | ||
$error = new CommaInDomain(); | ||
|
||
$expectedResult = new MultipleErrors([$error]); | ||
|
||
$lexer = $this->getMock("Egulias\\EmailValidator\\EmailLexer"); | ||
|
||
$validation1 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); | ||
$validation1->expects($this->any())->method("isValid")->willReturn(false); | ||
$validation1->expects($this->once())->method("getWarnings")->willReturn([]); | ||
$validation1->expects($this->once())->method("getError")->willReturn($error); | ||
|
||
$validation2 = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); | ||
$validation2->expects($this->never())->method("isValid"); | ||
$validation2->expects($this->never())->method("getWarnings"); | ||
$validation2->expects($this->never())->method("getError"); | ||
|
||
$multipleValidation = new MultipleValidationWithAnd([$validation1, $validation2], MultipleValidationWithAnd::STOP_ON_ERROR); | ||
$multipleValidation->isValid("[email protected]", $lexer); | ||
$this->assertEquals($expectedResult, $multipleValidation->getError()); | ||
} | ||
} |