Passed
Push — master ( dc7ccc...3b9fe6 )
by Mr
07:32
created

EmailTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 46
ccs 27
cts 27
cp 1
rs 10
c 1
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testToString() 0 3 1
A testGetDomain() 0 3 1
A testEquals() 0 6 1
A testGetLocalPart() 0 3 1
A testToNative() 0 4 1
A testMakeEmpty() 0 6 1
A setUp() 0 3 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/value-object project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Tests\ValueObject;
10
11
use Daikon\ValueObject\Email;
12
use PHPUnit\Framework\TestCase;
13
14
final class EmailTest extends TestCase
15
{
16
    private const EMAIL = '[email protected]';
17
18
    private Email $email;
19
20 1
    public function testToNative(): void
21
    {
22 1
        $this->assertEquals(self::EMAIL, $this->email->toNative());
23 1
        $this->assertEquals('', Email::fromNative(null)->toNative());
24 1
    }
25
26 1
    public function testEquals(): void
27
    {
28 1
        $sameEmail = Email::fromNative(self::EMAIL);
29 1
        $this->assertTrue($this->email->equals($sameEmail));
30 1
        $differentEmail = Email::fromNative('[email protected]');
31 1
        $this->assertFalse($this->email->equals($differentEmail));
32 1
    }
33
34 1
    public function testToString(): void
35
    {
36 1
        $this->assertEquals(self::EMAIL, (string)$this->email);
37 1
    }
38
39 1
    public function testGetLocalPart(): void
40
    {
41 1
        $this->assertEquals('peter.parker', (string)$this->email->getLocalPart());
42 1
    }
43
44 1
    public function testGetDomain(): void
45
    {
46 1
        $this->assertEquals('example.com', (string)$this->email->getDomain());
47 1
    }
48
49 1
    public function testMakeEmpty(): void
50
    {
51 1
        $email = Email::makeEmpty();
52 1
        $this->assertTrue($email->isEmpty());
53 1
        $this->assertNull($email->toNative());
54 1
        $this->assertEquals('', (string)$email);
55 1
    }
56
57 6
    protected function setUp(): void
58
    {
59 6
        $this->email = Email::fromNative(self::EMAIL);
60 6
    }
61
}
62