Test Failed
Push — master ( 37023c...961468 )
by Theo
01:47
created

EventTest::testItHasRequireValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace CalendarBundle\Tests\Entity;
4
5
use PhpSpec\ObjectBehavior;
0 ignored issues
show
Bug introduced by
The type PhpSpec\ObjectBehavior was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use CalendarBundle\Entity\Event;
7
use PHPUnit\Framework\TestCase;
8
9
class EventTest extends TestCase
10
{
11
    private $title;
12
    private $start;
13
    private $end;
14
    private $options;
15
16
    public function setUp(): void
17
    {
18
        $this->title = 'Title';
19
        $this->start = new \DateTime('2019-03-18 08:41:31');
20
        $this->end = new \DateTime('2019-03-18 08:41:31');
21
        $this->options = ['textColor' => 'blue'];
22
23
        $this->entity = new Event(
0 ignored issues
show
Bug Best Practice introduced by
The property entity does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
24
            $this->title,
25
            $this->start,
26
            $this->end,
27
            $this->options
28
        );
29
    }
30
31
    public function testItHasRequireValues()
32
    {
33
        $this->assertEquals($this->title, $this->entity->getTitle());
34
        $this->assertEquals($this->start, $this->entity->getStart());
35
        $this->assertEquals($this->end, $this->entity->getEnd());
36
        $this->assertEquals($this->options, $this->entity->getOptions());
37
    }
38
39
    public function testItShouldConvertItsValuesInToArray()
40
    {
41
        $url = 'url';
42
        $urlValue = 'www.url.com';
43
44
        $options = [
45
            $url => $urlValue,
46
        ];
47
48
        $allDay = false;
49
50
        $this->entity->setAllDay($allDay);
51
52
        $this->entity->addOption('be-removed', 'value');
53
        $this->entity->removeOption('be-removed');
54
55
        $this->assertEquals(null, $this->entity->removeOption('no-found-key'));
56
57
        $this->entity->setOptions($options);
58
        $this->assertEquals($options, $this->entity->getOptions());
59
60
        $this->assertEquals($urlValue, $this->entity->getOption($url, $urlValue));
61
62
        $this->assertEquals(
63
            [
64
                'title' => $this->title,
65
                'start' => $this->start->format('Y-m-d\\TH:i:sP'),
66
                'allDay' => $allDay,
67
                'end' => $this->end->format('Y-m-d\\TH:i:sP'),
68
                $url => $urlValue,
69
            ],
70
            $this->entity->toArray()
71
        );
72
    }
73
}
74