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

ResultTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testResultIsValidEmail() 0 10 1
A testResultIsInvalidEmail() 0 12 1
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
}