diff --git a/EmailValidator/Result/InvalidEmail.php b/EmailValidator/Result/InvalidEmail.php new file mode 100644 index 0000000..30bc859 --- /dev/null +++ b/EmailValidator/Result/InvalidEmail.php @@ -0,0 +1,33 @@ +token = $token; + $this->reason = $reason; + } + + public function isValid(): bool + { + return false; + } + + public function description(): string + { + return $this->reason->description() . " in char " . $this->token; + } + + public function code(): int + { + return $this->reason->code(); + } + +} \ No newline at end of file diff --git a/EmailValidator/Result/Reason/CharNotAllowed.php b/EmailValidator/Result/Reason/CharNotAllowed.php new file mode 100644 index 0000000..d174e5c --- /dev/null +++ b/EmailValidator/Result/Reason/CharNotAllowed.php @@ -0,0 +1,17 @@ +fail("implement"); + } +} \ No newline at end of file diff --git a/Tests/EmailValidator/Result/ResultTest.php b/Tests/EmailValidator/Result/ResultTest.php new file mode 100644 index 0000000..5f0c792 --- /dev/null +++ b/Tests/EmailValidator/Result/ResultTest.php @@ -0,0 +1,33 @@ +assertTrue($result->isValid()); + $this->assertEquals($expectedCode, $result->code()); + $this->assertEquals($expectedDescription, $result->description()); + } + + public function testResultIsInvalidEmail() + { + $reason = new CharNotAllowed(); + $token = "T"; + $result = new InvalidEmail($reason, $token); + $expectedCode = $reason->code(); + $expectedDescription = $reason->description() . " in char " . $token; + + $this->assertFalse($result->isValid()); + $this->assertEquals($expectedCode, $result->code()); + $this->assertEquals($expectedDescription, $result->description()); + } +} \ No newline at end of file