| @@ 28-39 (lines=12) @@ | ||
| 25 | $this->assertTrue($validator->isValid("[email protected]", $validation)); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function testMultipleValidation() |
|
| 29 | { |
|
| 30 | $invalidEmail = new InvalidEmail(new DummyReason(), ''); |
|
| 31 | $validator = new EmailValidator(); |
|
| 32 | $validation = $this->getMockBuilder(EmailValidation::class)->getMock(); |
|
| 33 | $validation->expects($this->once())->method("isValid")->willReturn(true); |
|
| 34 | $validation->expects($this->once())->method("getWarnings")->willReturn([]); |
|
| 35 | $validation->expects($this->exactly(2))->method("getError")->willReturn($invalidEmail); |
|
| 36 | $multiple = new MultipleValidationWithAnd([$validation]); |
|
| 37 | ||
| 38 | $this->assertTrue($validator->isValid("[email protected]", $multiple)); |
|
| 39 | } |
|
| 40 | ||
| 41 | public function testValidationIsFalse() |
|
| 42 | { |
|
| @@ 43-56 (lines=14) @@ | ||
| 40 | new MultipleValidationWithAnd([]); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function testValidationIsValid() |
|
| 44 | { |
|
| 45 | $lexer = new EmailLexer(); |
|
| 46 | $invalidEmail = new InvalidEmail(new DummyReason(), ''); |
|
| 47 | ||
| 48 | $validation = $this->getMockBuilder(EmailValidation::class)->getMock(); |
|
| 49 | $validation->expects($this->any())->method("isValid")->willReturn(true); |
|
| 50 | $validation->expects($this->once())->method("getWarnings")->willReturn([]); |
|
| 51 | $validation->expects($this->any())->method("getError")->willReturn($invalidEmail); |
|
| 52 | ||
| 53 | $multipleValidation = new MultipleValidationWithAnd([$validation]); |
|
| 54 | $this->assertTrue($multipleValidation->isValid("[email protected]", $lexer)); |
|
| 55 | $this->assertNull($multipleValidation->getError()); |
|
| 56 | } |
|
| 57 | ||
| 58 | public function testAccumulatesWarnings() |
|
| 59 | { |
|