Debian Codegraph @

t/01.parse.t

raw symbols SCIP
1 use strict;
2
3 use Test::More tests => 27;
4
5
6 use Data::ICal::DateTime;
7 use DateTime;
8 use DateTime::Set;
9 use DateTime::TimeZone;
10
11 # check the import stuff
12 ok(Data::ICal->can('events'),"Events");
13 for (qw(start end duration summary description url recurrence explode is_in _normalise)) {
14 ok(Data::ICal::Entry::Event->can($_),"Can $_");
15 }
16
17
18 my $cal;
19 ok($cal = Data::ICal->new( filename => 't/ics/test.ics'), "parse test ics");
20
21
22 my $date1 = DateTime->new( year => 2005, month => 6, day => 27 );
23 my $date2 = DateTime->new( year => 2005, month => 10, day => 27 );
24 my $set = DateTime::Span->from_datetimes( start => $date1, end => $date2 );
25
26 # $set->set_time_zone('Europe/London');
27
28 my @events;
29 @events = $cal->events;
30 is (@events, 128, "128 total events");
31
32 my ($orig_norm, $orig_recur);
33 for (@events) {
34 if ( $_->summary eq 'Potential Alternative London.pm social meet' ) {
35 $orig_norm = $_;
36 } elsif ( $_->summary eq 'London.pm tech meet') {
37 $orig_recur = $_;
38 }
39 }
40
41
42 @events = grep { $_->is_in($set) } @events;
43 is(@events, 10, "10 eligible events");
44
45
46 @events = $cal->events($set);
47 is(@events, 15, "15 events if you explode just recurring events");
48
49
50 my ($munged_norm, $munged_recur);
51 for (@events) {
52 if ( $_->summary eq 'Potential Alternative London.pm social meet' ) {
53 $munged_norm = $_;
54 } elsif ( $_->summary eq 'London.pm tech meet') {
55 $munged_recur = $_;
56 }
57 }
58
59
60
61 @events = $cal->events($set,'day');
62 is(@events, 36, "36 events if you explode multi day events to multiple single day events");
63
64 ok($orig_norm, "Found normal event");
65 ok($orig_recur, "Found recurring event");
66 ok($munged_norm, "Found munged normal event");
67 ok($munged_recur, "Found munged recurring event");
68
69 ok($orig_norm->duration,"Got a duration in the normal one");
70 ok(!$orig_norm->end,"Not got an end in the normal one");
71 ok(!$munged_norm->duration,"Not got a duration in the munged one");
72 ok($munged_norm->end,"Got an end in the munged one");
73
74
75
76 ok($orig_recur->recurrence,"Got a recurrence in the normal one");
77 ok(!$munged_recur->recurrence,"Not got a recurrence in the munged one");
78 ok($munged_recur->end,"Got an end in the munged one");
79