ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
VJournalTest.php
Go to the documentation of this file.
1 <?php
2 
4 
8 
9 class VJournalTest extends TestCase {
10 
14  function testInTimeRange(VJournal $vtodo, $start, $end, $outcome) {
15 
16  $this->assertEquals($outcome, $vtodo->isInTimeRange($start, $end));
17 
18  }
19 
20  function testValidate() {
21 
22  $input = <<<HI
23 BEGIN:VCALENDAR
24 VERSION:2.0
25 PRODID:YoYo
26 BEGIN:VJOURNAL
27 UID:12345678
28 DTSTAMP:20140402T174100Z
29 END:VJOURNAL
30 END:VCALENDAR
31 HI;
32 
33  $obj = Reader::read($input);
34 
35  $warnings = $obj->validate();
36  $messages = [];
37  foreach ($warnings as $warning) {
38  $messages[] = $warning['message'];
39  }
40 
41  $this->assertEquals([], $messages);
42 
43  }
44 
45  function testValidateBroken() {
46 
47  $input = <<<HI
48 BEGIN:VCALENDAR
49 VERSION:2.0
50 PRODID:YoYo
51 BEGIN:VJOURNAL
52 UID:12345678
53 DTSTAMP:20140402T174100Z
54 URL:http://example.org/
55 URL:http://example.com/
56 END:VJOURNAL
57 END:VCALENDAR
58 HI;
59 
60  $obj = Reader::read($input);
61 
62  $warnings = $obj->validate();
63  $messages = [];
64  foreach ($warnings as $warning) {
65  $messages[] = $warning['message'];
66  }
67 
68  $this->assertEquals(
69  ["URL MUST NOT appear more than once in a VJOURNAL component"],
70  $messages
71  );
72 
73  }
74 
75  function timeRangeTestData() {
76 
77  $calendar = new VCalendar();
78 
79  $tests = [];
80 
81  $vjournal = $calendar->createComponent('VJOURNAL');
82  $vjournal->DTSTART = '20111223T120000Z';
83  $tests[] = [$vjournal, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true];
84  $tests[] = [$vjournal, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false];
85 
86  $vjournal2 = $calendar->createComponent('VJOURNAL');
87  $vjournal2->DTSTART = '20111223';
88  $vjournal2->DTSTART['VALUE'] = 'DATE';
89  $tests[] = [$vjournal2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true];
90  $tests[] = [$vjournal2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false];
91 
92  $vjournal3 = $calendar->createComponent('VJOURNAL');
93  $tests[] = [$vjournal3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), false];
94  $tests[] = [$vjournal3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false];
95 
96  return $tests;
97  }
98 
99 
100 
101 }
if($argc< 3) $input
The VCalendar component.
Definition: VCalendar.php:23
VJournal component.
Definition: VJournal.php:17
$start
Definition: bench.php:8
$messages
Definition: en.php:5
static http()
Fetches the global http state from ILIAS.
$tests
Definition: bench.php:104
$warning
Definition: X509warning.php:13
static read($data, $options=0, $charset='UTF-8')
Parses a vCard or iCalendar object, and returns the top component.
Definition: Reader.php:42
testInTimeRange(VJournal $vtodo, $start, $end, $outcome)
timeRangeTestData
isInTimeRange(DateTimeInterface $start, DateTimeInterface $end)
Returns true or false depending on if the event falls in the specified time-range.
Definition: VJournal.php:31