annotate vendor/sabre/vobject/tests/VObject/Component/VEventTest.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1 <?php
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
3 namespace Sabre\VObject\Component;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
5 use Sabre\VObject;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
6
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
7 class VEventTest extends \PHPUnit_Framework_TestCase {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
8
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
9 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
10 * @dataProvider timeRangeTestData
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
11 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
12 public function testInTimeRange(VEvent $vevent,$start,$end,$outcome) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
13
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
14 $this->assertEquals($outcome, $vevent->isInTimeRange($start, $end));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
15
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
16 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
17
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
18 public function timeRangeTestData() {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
19
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
20 $tests = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
21
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
22 $calendar = new VCalendar();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
23
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
24 $vevent = $calendar->createComponent('VEVENT');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
25 $vevent->DTSTART = '20111223T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
26 $tests[] = array($vevent, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
27 $tests[] = array($vevent, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
28
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
29 $vevent2 = clone $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
30 $vevent2->DTEND = '20111225T120000Z';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
31 $tests[] = array($vevent2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
32 $tests[] = array($vevent2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
33
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
34 $vevent3 = clone $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
35 $vevent3->DURATION = 'P1D';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
36 $tests[] = array($vevent3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
37 $tests[] = array($vevent3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
38
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
39 $vevent4 = clone $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
40 $vevent4->DTSTART = '20111225';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
41 $vevent4->DTSTART['VALUE'] = 'DATE';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
42 $tests[] = array($vevent4, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
43 $tests[] = array($vevent4, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
44 // Event with no end date should be treated as lasting the entire day.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
45 $tests[] = array($vevent4, new \DateTime('2011-12-25 16:00:00'), new \DateTime('2011-12-25 17:00:00'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
46
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
47
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
48 $vevent5 = clone $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
49 $vevent5->DURATION = 'P1D';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
50 $vevent5->RRULE = 'FREQ=YEARLY';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
51 $tests[] = array($vevent5, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
52 $tests[] = array($vevent5, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
53 $tests[] = array($vevent5, new \DateTime('2013-12-01'), new \DateTime('2013-12-31'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
54
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
55 $vevent6 = clone $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
56 $vevent6->DTSTART = '20111225';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
57 $vevent6->DTSTART['VALUE'] = 'DATE';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
58 $vevent6->DTEND = '20111225';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
59 $vevent6->DTEND['VALUE'] = 'DATE';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
60
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
61 $tests[] = array($vevent6, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
62 $tests[] = array($vevent6, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
63
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
64 // Added this test to ensure that recurrence rules with no DTEND also
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
65 // get checked for the entire day.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
66 $vevent7 = clone $vevent;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
67 $vevent7->DTSTART = '20120101';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
68 $vevent7->DTSTART['VALUE'] = 'DATE';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
69 $vevent7->RRULE = 'FREQ=MONTHLY';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
70 $tests[] = array($vevent7, new \DateTime('2012-02-01 15:00:00'), new \DateTime('2012-02-02'), true);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
71 return $tests;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
72
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
73 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
74
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
75 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
76