Passed
Push — 1.0.0 ( 681a4e...b8a5a2 )
by Alex
01:34
created

EmailTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGivenAValidEmailAValidVOIsReturned() 0 11 1
A testGivenAnInvalidEmailAnExceptionIsThrown() 0 10 1
1
<?php
2
3
namespace StraTDeS\VO\Tests;
4
5
use StraTDeS\VO\Email;
6
use PHPUnit\Framework\TestCase;
7
8
class EmailTest extends TestCase
9
{
10
    public function testGivenAValidEmailAValidVOIsReturned(): void
11
    {
12
        // Arrange
13
        $email = "[email protected]";
14
15
        // Act
16
        $emailVO = Email::fromValue($email);
17
18
        // Assert
19
        $this->assertInstanceOf(Email::class, $emailVO);
20
        $this->assertEquals($email, $emailVO->value());
21
    }
22
23
    public function testGivenAnInvalidEmailAnExceptionIsThrown(): void
24
    {
25
        $this->expectException(\InvalidArgumentException::class);
26
        $this->expectExceptionMessage("foo@bar is not a valid email");
27
28
        // Arrange
29
        $email = "foo@bar";
30
31
        // Act
32
        Email::fromValue($email);
33
    }
34
}
35