File: ResultTest.php

package info (click to toggle)
php-email-validator 4.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 760 kB
  • sloc: php: 3,534; makefile: 19; xml: 18
file content (35 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

namespace Egulias\EmailValidator\Tests\EmailValidator\Result;

use PHPUnit\Framework\TestCase;
use Egulias\EmailValidator\Result\ValidEmail;
use Egulias\EmailValidator\Result\InvalidEmail;
use Egulias\EmailValidator\Result\Reason\CharNotAllowed;

class ResultTest extends TestCase
{
    public function testResultIsValidEmail()
    {
        $result = new ValidEmail();
        $expectedCode = 0;
        $expectedDescription = "Valid email";

        $this->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());
    }
}