EventTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 38
c 1
b 0
f 0
dl 0
loc 63
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testItHasRequireValues() 0 6 1
A setUp() 0 12 1
A testItShouldConvertItsValuesInToArray() 0 32 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CalendarBundle\Tests\Entity;
6
7
use CalendarBundle\Entity\Event;
8
use PHPUnit\Framework\TestCase;
9
10
class EventTest extends TestCase
11
{
12
    private $title;
13
    private $start;
14
    private $end;
15
    private $options;
16
    private $entity;
17
18
    public function setUp(): void
19
    {
20
        $this->title = 'Title';
21
        $this->start = new \DateTime('2019-03-18 08:41:31');
22
        $this->end = new \DateTime('2019-03-18 08:41:31');
23
        $this->options = ['textColor' => 'blue'];
24
25
        $this->entity = new Event(
26
            $this->title,
27
            $this->start,
28
            $this->end,
29
            $this->options
30
        );
31
    }
32
33
    public function testItHasRequireValues()
34
    {
35
        $this->assertEquals($this->title, $this->entity->getTitle());
36
        $this->assertEquals($this->start, $this->entity->getStart());
37
        $this->assertEquals($this->end, $this->entity->getEnd());
38
        $this->assertEquals($this->options, $this->entity->getOptions());
39
    }
40
41
    public function testItShouldConvertItsValuesInToArray()
42
    {
43
        $url = 'url';
44
        $urlValue = 'www.url.com';
45
46
        $options = [
47
            $url => $urlValue,
48
        ];
49
50
        $allDay = false;
51
52
        $this->entity->setAllDay($allDay);
53
54
        $this->entity->addOption('be-removed', 'value');
55
        $this->entity->removeOption('be-removed');
56
57
        $this->assertNull($this->entity->removeOption('no-found-key'));
58
59
        $this->entity->setOptions($options);
60
        $this->assertEquals($options, $this->entity->getOptions());
61
62
        $this->assertEquals($urlValue, $this->entity->getOption($url, $urlValue));
63
64
        $this->assertEquals(
65
            [
66
                'title' => $this->title,
67
                'start' => $this->start->format(Event::DATE_FORMAT),
68
                'allDay' => $allDay,
69
                'end' => $this->end->format(Event::DATE_FORMAT),
70
                $url => $urlValue,
71
            ],
72
            $this->entity->toArray()
73
        );
74
    }
75
}
76