Completed
Pull Request — master (#144)
by Markus
01:13
created

CalendarFactoryTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testMinimalEvent() 0 25 1
1
<?php
2
3
/*
4
 * This file is part of the eluceo/iCal package.
5
 *
6
 * (c) 2019 Markus Poerschke <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Unit\Presentation\Factory;
13
14
use DateTimeImmutable;
15
use DateTimeZone;
16
use Eluceo\iCal\Domain\Entity\Event;
17
use Eluceo\iCal\Domain\ValueObject\Timestamp;
18
use Eluceo\iCal\Domain\ValueObject\UniqueIdentifier;
19
use Eluceo\iCal\Presentation\Component;
20
use Eluceo\iCal\Presentation\Factory\EventFactory;
21
use PHPUnit\Framework\TestCase;
22
23
class CalendarFactoryTest extends TestCase
24
{
25
    public function testMinimalEvent()
26
    {
27
        $currentTime = Timestamp::fromDateTimeInterface(
28
            DateTimeImmutable::createFromFormat(
29
                'Y-m-d H:i:s',
30
                '2019-11-10 11:22:33',
31
                new DateTimeZone('UTC')
32
            )
33
        );
34
        $event = Event::create(UniqueIdentifier::fromString('event1'))
35
            ->touch($currentTime)
36
            ->setSummary('Lorem Summary')
37
            ->setDescription('Lorem Description');
38
39
        $expected = implode(Component::LINE_SEPARATOR, [
40
            'BEGIN:VEVENT',
41
            'UID:event1',
42
            'DTSTAMP:20191110T112233Z',
43
            'SUMMARY:Lorem Summary',
44
            'DESCRIPTION:Lorem Description',
45
            'END:VEVENT',
46
        ]);
47
48
        self::assertSame($expected, (string) (new EventFactory())->createComponent($event));
49
    }
50
}
51