comparison vendor/sabre/vobject/tests/VObject/Component/VJournalTest.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
comparison
equal deleted inserted replaced
6:cec75ba50afc 7:430dbd5346f7
1 <?php
2
3 namespace Sabre\VObject\Component;
4
5 use Sabre\VObject\Component;
6 use Sabre\VObject\Reader;
7
8 class VJournalTest extends \PHPUnit_Framework_TestCase {
9
10 /**
11 * @dataProvider timeRangeTestData
12 */
13 public function testInTimeRange(VJournal $vtodo,$start,$end,$outcome) {
14
15 $this->assertEquals($outcome, $vtodo->isInTimeRange($start, $end));
16
17 }
18
19 public function testValidate() {
20
21 $input = <<<HI
22 BEGIN:VCALENDAR
23 VERSION:2.0
24 PRODID:YoYo
25 BEGIN:VJOURNAL
26 UID:12345678
27 DTSTAMP:20140402T174100Z
28 END:VJOURNAL
29 END:VCALENDAR
30 HI;
31
32 $obj = Reader::read($input);
33
34 $warnings = $obj->validate();
35 $messages = array();
36 foreach($warnings as $warning) {
37 $messages[] = $warning['message'];
38 }
39
40 $this->assertEquals(array(), $messages);
41
42 }
43
44 public function testValidateBroken() {
45
46 $input = <<<HI
47 BEGIN:VCALENDAR
48 VERSION:2.0
49 PRODID:YoYo
50 BEGIN:VJOURNAL
51 UID:12345678
52 DTSTAMP:20140402T174100Z
53 URL:http://example.org/
54 URL:http://example.com/
55 END:VJOURNAL
56 END:VCALENDAR
57 HI;
58
59 $obj = Reader::read($input);
60
61 $warnings = $obj->validate();
62 $messages = array();
63 foreach($warnings as $warning) {
64 $messages[] = $warning['message'];
65 }
66
67 $this->assertEquals(
68 array("URL MUST NOT appear more than once in a VJOURNAL component"),
69 $messages
70 );
71
72 }
73
74 public function timeRangeTestData() {
75
76 $calendar = new VCalendar();
77
78 $tests = array();
79
80 $vjournal = $calendar->createComponent('VJOURNAL');
81 $vjournal->DTSTART = '20111223T120000Z';
82 $tests[] = array($vjournal, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
83 $tests[] = array($vjournal, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
84
85 $vjournal2 = $calendar->createComponent('VJOURNAL');
86 $vjournal2->DTSTART = '20111223';
87 $vjournal2->DTSTART['VALUE'] = 'DATE';
88 $tests[] = array($vjournal2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
89 $tests[] = array($vjournal2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
90
91 $vjournal3 = $calendar->createComponent('VJOURNAL');
92 $tests[] = array($vjournal3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), false);
93 $tests[] = array($vjournal3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);
94
95 return $tests;
96 }
97
98
99
100 }
101