EntityTests   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testId() 0 10 1
A testEquals() 0 12 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Domain\Model\Tests\Units;
12
13
use Cubiche\Domain\Model\Tests\Fixtures\Category;
14
use Cubiche\Domain\Model\Tests\Fixtures\CategoryId;
15
16
/**
17
 * EntityTestCase class.
18
 *
19
 * @author Ivannis Suárez Jerez <[email protected]>
20
 */
21
class EntityTests extends TestCase
22
{
23
    /**
24
     * Test id method.
25
     */
26
    public function testId()
27
    {
28
        $this
29
            ->given($id = CategoryId::fromNative($this->faker->ean13()))
30
            ->and($entity = new Category($id))
31
            ->then()
32
                ->boolean($entity->id()->equals($id))
33
                    ->isTrue()
34
        ;
35
    }
36
37
    /**
38
     * Test equals method.
39
     */
40
    public function testEquals()
41
    {
42
        $this
43
            ->given($entity1 = new Category(CategoryId::fromNative($this->faker->unique()->uuid())))
44
            ->and($entity2 = new Category(CategoryId::fromNative($this->faker->ean13())))
45
            ->then()
46
                ->boolean($entity1->equals($entity1))
47
                    ->isTrue()
48
                ->boolean($entity1->equals($entity2))
49
                    ->isFalse()
50
        ;
51
    }
52
}
53