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