EntityTests::testEquals()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
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