Test Setup Failed
Push — 3.0.0-dev ( ab6a4f...442f13 )
by Eduardo Gulias
01:45
created

ResultTest::testResultIsInvalidEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Egulias\Tests\EmailValidator\Validation;
4
5
use PHPUnit\Framework\TestCase;
6
use Egulias\EmailValidator\Result\ValidEmail;
7
use Egulias\EmailValidator\Result\InvalidEmail;
8
use Egulias\EmailValidator\Result\Reason\CharNotAllowed;
9
10
class ResultTest extends TestCase
11
{
12
    public function testResultIsValidEmail()
13
    {
14
        $result = new ValidEmail();
15
        $expectedCode = 0;
16
        $expectedDescription = "Valid email";
17
18
        $this->assertTrue($result->isValid());
19
        $this->assertEquals($expectedCode, $result->code());
20
        $this->assertEquals($expectedDescription, $result->description());
21
    }
22
23
    public function testResultIsInvalidEmail()
24
    {
25
        $reason = new CharNotAllowed();
26
        $token = "T";
27
        $result = new InvalidEmail($reason, $token);
28
        $expectedCode = $reason->code();
29
        $expectedDescription = $reason->description() . " in char " . $token;
30
31
        $this->assertFalse($result->isValid());
32
        $this->assertEquals($expectedCode, $result->code());
33
        $this->assertEquals($expectedDescription, $result->description());
34
    }
35
}