1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\CalendarBundle\Entity; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use CalendarBundle\Entity\Event; |
7
|
|
|
|
8
|
|
|
class EventSpec extends ObjectBehavior |
9
|
|
|
{ |
10
|
|
|
private $title = 'Title'; |
11
|
|
|
private $start; |
12
|
|
|
private $end = null; |
13
|
|
|
private $options = []; |
14
|
|
|
|
15
|
|
|
public function let() |
16
|
|
|
{ |
17
|
|
|
$this->start = new \DateTime('2019-03-18 08:41:31'); |
18
|
|
|
$this->end = new \DateTime('2019-03-18 08:41:31'); |
19
|
|
|
$this->options = ['textColor' => 'blue']; |
20
|
|
|
|
21
|
|
|
$this->beAnInstanceOf(Event::class); |
22
|
|
|
$this->beConstructedWith($this->title, $this->start, $this->end, $this->options); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function it_is_initializable() |
26
|
|
|
{ |
27
|
|
|
$this->shouldHaveType(Event::class); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function it_has_require_values() |
31
|
|
|
{ |
32
|
|
|
$this->getTitle()->shouldReturn($this->title); |
|
|
|
|
33
|
|
|
$this->getStart()->shouldReturn($this->start); |
|
|
|
|
34
|
|
|
$this->getEnd()->shouldReturn($this->end); |
|
|
|
|
35
|
|
|
$this->getOptions()->shouldReturn($this->options); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function it_should_convert_its_values_in_to_array() |
39
|
|
|
{ |
40
|
|
|
$url = 'url'; |
41
|
|
|
$urlValue = 'www.url.com'; |
42
|
|
|
|
43
|
|
|
$options = [ |
44
|
|
|
$url => $urlValue, |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
$allDay = false; |
48
|
|
|
|
49
|
|
|
$this->setAllDay($allDay); |
|
|
|
|
50
|
|
|
|
51
|
|
|
$this->addOption('be-removed', 'value'); |
|
|
|
|
52
|
|
|
$this->removeOption('be-removed'); |
|
|
|
|
53
|
|
|
|
54
|
|
|
$this->removeOption('no-found-key')->shouldReturn(null); |
55
|
|
|
|
56
|
|
|
$this->setOptions($options); |
|
|
|
|
57
|
|
|
$this->getOptions()->shouldReturn($options); |
58
|
|
|
|
59
|
|
|
$this->getOption($url, $urlValue)->shouldReturn($urlValue); |
|
|
|
|
60
|
|
|
|
61
|
|
|
$this->toArray()->shouldReturn( |
|
|
|
|
62
|
|
|
[ |
63
|
|
|
'title' => $this->title, |
64
|
|
|
'start' => $this->start->format('Y-m-d\\TH:i:sP'), |
65
|
|
|
'allDay' => $allDay, |
66
|
|
|
'end' => $this->end->format('Y-m-d\\TH:i:sP'), |
67
|
|
|
$url => $urlValue, |
68
|
|
|
] |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|