@@ 10-19 (lines=10) @@ | ||
7 | ||
8 | class EmailValidatorTest extends \PHPUnit_Framework_TestCase |
|
9 | { |
|
10 | public function testValidationIsUsed() |
|
11 | { |
|
12 | $validator = new EmailValidator(); |
|
13 | $validation = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); |
|
14 | $validation->expects($this->once())->method("isValid")->willReturn(true); |
|
15 | $validation->expects($this->once())->method("getWarnings")->willReturn([]); |
|
16 | $validation->expects($this->once())->method("getError")->willReturn(null); |
|
17 | ||
18 | $this->assertTrue($validator->isValid("[email protected]", $validation)); |
|
19 | } |
|
20 | ||
21 | public function testMultipleValidation() |
|
22 | { |
|
@@ 21-31 (lines=11) @@ | ||
18 | $this->assertTrue($validator->isValid("[email protected]", $validation)); |
|
19 | } |
|
20 | ||
21 | public function testMultipleValidation() |
|
22 | { |
|
23 | $validator = new EmailValidator(); |
|
24 | $validation = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); |
|
25 | $validation->expects($this->once())->method("isValid")->willReturn(true); |
|
26 | $validation->expects($this->once())->method("getWarnings")->willReturn([]); |
|
27 | $validation->expects($this->once())->method("getError")->willReturn(null); |
|
28 | $multiple = new MultipleValidationWithAnd([$validation]); |
|
29 | ||
30 | $this->assertTrue($validator->isValid("[email protected]", $multiple)); |
|
31 | } |
|
32 | } |
|
33 |
@@ 35-46 (lines=12) @@ | ||
32 | new MultipleValidationWithAnd([]); |
|
33 | } |
|
34 | ||
35 | public function testValidationIsFine() |
|
36 | { |
|
37 | $lexer = $this->getMock("Egulias\\EmailValidator\\EmailLexer"); |
|
38 | ||
39 | $validation = $this->getMock("Egulias\\EmailValidator\\Validation\\EmailValidation"); |
|
40 | $validation->expects($this->any())->method("isValid")->willReturn(true); |
|
41 | $validation->expects($this->once())->method("getWarnings")->willReturn([]); |
|
42 | ||
43 | $multipleValidation = new MultipleValidationWithAnd([$validation]); |
|
44 | $this->assertTrue($multipleValidation->isValid("[email protected]", $lexer)); |
|
45 | $this->assertNull($multipleValidation->getError()); |
|
46 | } |
|
47 | ||
48 | public function testAccumulatesWarnings() |
|
49 | { |