1<?php
2
3namespace Sabre\VObject\ITip;
4
5use Sabre\VObject\Reader;
6
7class BrokerTimezoneInParseEventInfoWithoutMasterTest extends \PHPUnit_Framework_TestCase {
8
9    function testTimezoneInParseEventInfoWithoutMaster()
10    {
11        $calendar = <<<ICS
12BEGIN:VCALENDAR
13VERSION:2.0
14PRODID:-//Apple Inc.//Mac OS X 10.9.5//EN
15CALSCALE:GREGORIAN
16BEGIN:VTIMEZONE
17TZID:Europe/Minsk
18BEGIN:DAYLIGHT
19TZOFFSETFROM:+0200
20RRULE:FREQ=YEARLY;UNTIL=20100328T000000Z;BYMONTH=3;BYDAY=-1SU
21DTSTART:19930328T020000
22TZNAME:GMT+3
23TZOFFSETTO:+0300
24END:DAYLIGHT
25BEGIN:STANDARD
26TZOFFSETFROM:+0200
27DTSTART:20110327T020000
28TZNAME:GMT+3
29TZOFFSETTO:+0300
30RDATE:20110327T020000
31END:STANDARD
32END:VTIMEZONE
33BEGIN:VEVENT
34CREATED:20160331T163031Z
35UID:B9301437-417C-4136-8DB3-8D1555863791
36DTEND;TZID=Europe/Minsk:20160405T100000
37TRANSP:OPAQUE
38ATTENDEE;CN=User Invitee;CUTYPE=INDIVIDUAL;EMAIL=invitee@test.com;PARTSTAT=
39 ACCEPTED;ROLE=REQ-PARTICIPANT:mailto:invitee@test.com
40ATTENDEE;CN=User Organizer;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:organ
41 izer@test.com
42SUMMARY:Event title
43DTSTART;TZID=Europe/Minsk:20160405T090000
44DTSTAMP:20160331T164108Z
45ORGANIZER;CN=User Organizer:mailto:organizer@test.com
46SEQUENCE:6
47RECURRENCE-ID;TZID=Europe/Minsk:20160405T090000
48END:VEVENT
49BEGIN:VEVENT
50CREATED:20160331T163031Z
51UID:B9301437-417C-4136-8DB3-8D1555863791
52DTEND;TZID=Europe/Minsk:20160406T100000
53TRANSP:OPAQUE
54ATTENDEE;CN=User Invitee;CUTYPE=INDIVIDUAL;EMAIL=invitee@test.com;PARTSTAT=
55 ACCEPTED;ROLE=REQ-PARTICIPANT:mailto:invitee@test.com
56ATTENDEE;CN=User Organizer;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:organ
57 izer@test.com
58SUMMARY:Event title
59DTSTART;TZID=Europe/Minsk:20160406T090000
60DTSTAMP:20160331T165845Z
61ORGANIZER;CN=User Organizer:mailto:organizer@test.com
62SEQUENCE:6
63RECURRENCE-ID;TZID=Europe/Minsk:20160406T090000
64END:VEVENT
65END:VCALENDAR
66ICS;
67
68        $calendar = Reader::read($calendar);
69        $broker = new Broker();
70
71        $reflectionMethod = new \ReflectionMethod($broker, 'parseEventInfo');
72        $reflectionMethod->setAccessible(true);
73        $data = $reflectionMethod->invoke($broker, $calendar);
74        $this->assertInstanceOf('DateTimeZone', $data['timezone']);
75        $this->assertEquals($data['timezone']->getName(), 'Europe/Minsk');
76    }
77}
78