Completed
Push — develop ( 81716f )
by Stefano
16:01
created

AbstractEntityTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 39
c 1
b 0
f 0
wmc 4
lcom 1
cbo 5
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testUuid() 0 9 1
A testUuidIsAutomaticallyGenerated() 0 8 1
A testUuidFromString() 0 9 1
A testCloningChangesUuid() 0 7 1
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\Persistence\Test\Entity;
9
10
use PHPUnit_Framework_TestCase as TestCase;
11
use Ramsey\Uuid\Uuid;
12
use Thorr\Persistence\Entity\AbstractEntity;
13
use Thorr\Persistence\Test\Asset\TestEntity;
14
15
class AbstractEntityTest extends TestCase
16
{
17
    public function testUuid()
18
    {
19
        $uuid = Uuid::uuid4();
20
21
        /** @var AbstractEntity $entity */
22
        $entity = $this->getMockForAbstractClass(AbstractEntity::class, [ $uuid ]);
23
24
        $this->assertEquals($uuid, $entity->getUuid());
25
    }
26
27
    public function testUuidIsAutomaticallyGenerated()
28
    {
29
        /** @var AbstractEntity $entity */
30
        $entity = $this->getMockForAbstractClass(AbstractEntity::class);
31
32
        $this->assertNotEmpty($entity->getUuid());
33
        $this->assertTrue(Uuid::isValid($entity->getUuid()));
34
    }
35
36
    public function testUuidFromString()
37
    {
38
        $uuid = Uuid::uuid4()->toString();
39
40
        /** @var AbstractEntity $entity */
41
        $entity = $this->getMockForAbstractClass(AbstractEntity::class, [ $uuid ]);
42
43
        $this->assertSame($uuid, $entity->getUuid());
44
    }
45
46
    public function testCloningChangesUuid()
47
    {
48
        $entity = new TestEntity();
49
50
        $clone = clone $entity;
51
        $this->assertNotEquals($entity->getUuid(), $clone->getUuid());
52
    }
53
}
54