Passed
Branch master (bb3df7)
by Theo
01:32
created

SerializerSpec::it_is_initializable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\CalendarBundle\Serializer;
4
5
use PhpSpec\ObjectBehavior;
6
use Prophecy\Argument;
7
use CalendarBundle\Entity\Event;
8
use CalendarBundle\Serializer\Serializer;
9
10
class SerializerSpec extends ObjectBehavior
11
{
12
    public function it_is_initializable()
13
    {
14
        $this->shouldHaveType(Serializer::class);
15
    }
16
17
    public function it_serialzes_data_successfully(Event $event1, Event $event2)
18
    {
19
        $event1->toArray()->shouldBeCalled()->willReturn(
20
            [
21
                'title' => 'Event 1',
22
                'start' => '2015-01-20T11:50:00Z',
23
                'allDay' => false,
24
                'end' => '2015-01-21T11:50:00Z',
25
            ]
26
        );
27
        $event2->toArray()->shouldBeCalled()->willReturn(
28
            [
29
                'title' => 'Event 2',
30
                'start' => '2015-01-22T11:50:00Z',
31
                'allDay' => true,
32
            ]
33
        );
34
35
        $data = [
36
            [
37
                'title' => 'Event 1',
38
                'start' => '2015-01-20T11:50:00Z',
39
                'allDay' => false,
40
                'end' => '2015-01-21T11:50:00Z',
41
            ],
42
            [
43
                'title' => 'Event 2',
44
                'start' => '2015-01-22T11:50:00Z',
45
                'allDay' => true,
46
            ]
47
        ];
48
49
        $this
50
            ->serialize([$event1, $event2])
0 ignored issues
show
Bug introduced by
The method serialize() does not exist on Tests\CalendarBundle\Serializer\SerializerSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
            ->/** @scrutinizer ignore-call */ 
51
              serialize([$event1, $event2])
Loading history...
51
            ->shouldReturn(json_encode($data));
52
    }
53
54
    public function it_serialzes_should_return_emtpy_if_events_are_empty()
55
    {
56
        $this->serialize([])->shouldReturn('[]');
57
    }
58
}
59