Passed
Pull Request — master (#10)
by Anatoly
02:48
created

EntryTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 26
c 1
b 0
f 1
dl 0
loc 56
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testEvents() 0 15 1
A testConstructor() 0 8 1
A testName() 0 6 1
A testSlug() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace App\Bundle\Example\Tests\Entity;
4
5
/**
6
 * Import classes
7
 */
8
use App\Bundle\Example\Entity\Entry;
9
use PHPUnit\Framework\TestCase;
10
use Ramsey\Uuid\UuidInterface;
11
use DateTimeInterface;
12
13
/**
14
 * EntryTest
15
 */
16
class EntryTest extends TestCase
17
{
18
19
    /**
20
     * @return void
21
     */
22
    public function testConstructor() : void
23
    {
24
        $entry = new Entry();
25
        $this->assertInstanceOf(UuidInterface::class, $entry->getId());
26
        $this->assertSame('', $entry->getName());
27
        $this->assertSame('', $entry->getSlug());
28
        $this->assertNull($entry->getCreatedAt());
29
        $this->assertNull($entry->getUpdatedAt());
30
    }
31
32
    /**
33
     * @return void
34
     */
35
    public function testName() : void
36
    {
37
        $entry = new Entry();
38
        $this->assertSame('', $entry->getName());
39
        $entry->setName('foo');
40
        $this->assertSame('foo', $entry->getName());
41
    }
42
43
    /**
44
     * @return void
45
     */
46
    public function testSlug() : void
47
    {
48
        $entry = new Entry();
49
        $this->assertSame('', $entry->getSlug());
50
        $entry->setSlug('foo');
51
        $this->assertSame('foo', $entry->getSlug());
52
    }
53
54
    /**
55
     * @return void
56
     */
57
    public function testEvents() : void
58
    {
59
        $entry = new Entry();
60
        $this->assertNull($entry->getCreatedAt());
61
        $this->assertNull($entry->getUpdatedAt());
62
63
        $entry = new Entry();
64
        $entry->prePersist();
65
        $this->assertInstanceOf(DateTimeInterface::class, $entry->getCreatedAt());
66
        $this->assertNull($entry->getUpdatedAt());
67
68
        $entry = new Entry();
69
        $entry->preUpdate();
70
        $this->assertNull($entry->getCreatedAt());
71
        $this->assertInstanceOf(DateTimeInterface::class, $entry->getUpdatedAt());
72
    }
73
}
74