Completed
Push — master ( 3b3980...4ce207 )
by Gorka
9s
created

it_compares_different_email_addresses()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Spec\Kreta\SharedKernel\Domain\Model\Identity;
14
15
use Kreta\SharedKernel\Domain\Model\Identity\EmailAddress;
16
use Kreta\SharedKernel\Domain\Model\Identity\EmailAddressInvalidException;
17
use PhpSpec\ObjectBehavior;
18
19
class EmailAddressSpec extends ObjectBehavior
20
{
21
    function it_constructs_with_valid_email_address()
22
    {
23
        $this->beConstructedWith('[email protected]');
24
        $this->shouldHaveType(EmailAddress::class);
25
26
        $this->email()->shouldBe('[email protected]');
27
        $this->domain()->shouldBe('user.com');
28
        $this->localPart()->shouldBe('bengor');
29
        $this->__toString()->shouldBe('[email protected]');
30
    }
31
32
    function it_constructs_with_invalid_email_address()
33
    {
34
        $this->beConstructedWith('invalid string');
35
36
        $this->shouldThrow(EmailAddressInvalidException::class)->duringInstantiation();
37
    }
38
39
    function it_compares_email_addresses()
40
    {
41
        $this->beConstructedWith('[email protected]');
42
43
        $this->equals(new EmailAddress('[email protected]'))->shouldBe(true);
44
    }
45
46
    function it_compares_different_email_addresses()
47
    {
48
        $this->beConstructedWith('[email protected]');
49
50
        $this->equals(new EmailAddress('[email protected]'))->shouldBe(false);
51
    }
52
}
53