~ubuntu-branches/ubuntu/vivid/php-horde-icalendar/vivid-proposed

« back to all changes in this revision

Viewing changes to Horde_Icalendar-2.0.5/test/Horde/Icalendar/ExportTest.php

  • Committer: Package Import Robot
  • Author(s): Mathieu Parent
  • Date: 2013-05-14 20:46:43 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130514204643-xq5x2ezjku3om1um
Tags: 2.0.5-1
New upstream version 2.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/**
 
3
 * @category   Horde
 
4
 * @package    Icalendar
 
5
 * @subpackage UnitTests
 
6
 */
 
7
 
 
8
/**
 
9
 * @category   Horde
 
10
 * @package    Icalendar
 
11
 * @subpackage UnitTests
 
12
 */
 
13
class Horde_Icalendar_ExportTest extends Horde_Test_Case
 
14
{
 
15
    public function testLineFolding()
 
16
    {
 
17
        $ical = new Horde_Icalendar();
 
18
        $event = Horde_Icalendar::newComponent('vevent', $ical);
 
19
        $event->setAttribute('UID', 'XXX');
 
20
        $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
21
        $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
22
        $event->setAttribute('DESCRIPTION', 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam sollicitudin faucibus mauris amet.');
 
23
        $event->setAttribute('BINARY', base64_encode('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam sollicitudin faucibus mauris amet.'), array('ENCODING' => 'b'));
 
24
        $ical->addComponent($event);
 
25
        $this->assertStringEqualsFile(
 
26
            __DIR__ . '/fixtures/line-folding-1.ics',
 
27
            $ical->exportVCalendar()
 
28
        );
 
29
 
 
30
        $ical = new Horde_Icalendar('1.0');
 
31
        $event = Horde_Icalendar::newComponent('vevent', $ical);
 
32
        $event->setAttribute('UID', 'XXX');
 
33
        $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
34
        $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
35
        $event->setAttribute('DESCRIPTION', 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam sollicitudin faucibus mauris amet.');
 
36
        $ical->addComponent($event);
 
37
        $this->assertStringEqualsFile(
 
38
            __DIR__ . '/fixtures/line-folding-2.ics',
 
39
            $ical->exportVCalendar()
 
40
        );
 
41
 
 
42
        $ical = new Horde_Icalendar();
 
43
        $event = Horde_Icalendar::newComponent('vevent', $ical);
 
44
        $event->setAttribute('UID', 'XXX');
 
45
        $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
46
        $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
47
        $event->setAttribute('DESCRIPTION', 'Lörem ipsüm dölör sit ämet, cönsectetüer ädipiscing elit. Aliqüäm söllicitüdin fäücibüs mäüris ämet.');
 
48
        $ical->addComponent($event);
 
49
        $this->assertStringEqualsFile(
 
50
            __DIR__ . '/fixtures/line-folding-3.ics',
 
51
            $ical->exportVCalendar()
 
52
        );
 
53
 
 
54
        $ical = new Horde_Icalendar('1.0');
 
55
        $event = Horde_Icalendar::newComponent('vevent', $ical);
 
56
        $event->setAttribute('UID', 'XXX');
 
57
        $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
58
        $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
59
        $event->setAttribute('DESCRIPTION', 'Lörem ipsüm dölör sit ämet, cönsectetüer ädipiscing elit. Aliqüäm söllicitüdin fäücibüs mäüris ämet.', array('CHARSET' => 'UTF-8'));
 
60
        $ical->addComponent($event);
 
61
        $this->assertStringEqualsFile(
 
62
            __DIR__ . '/fixtures/line-folding-4.ics',
 
63
            $ical->exportVCalendar()
 
64
        );
 
65
 
 
66
        $ical = new Horde_Icalendar('1.0');
 
67
        $event = Horde_Icalendar::newComponent('vevent', $ical);
 
68
        $event->setAttribute('UID', 'XXX');
 
69
        $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
70
        $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
71
        $event->setAttribute('DESCRIPTION', 'Löremipsümdölörsitämet,cönsectetüerädipiscingelit.Aliqüämsöllicitüdinfäücibüsmäürisämet. Löremipsümdölörsitämet,cönsectetüerädipiscingelit.Aliqüämsöllicitüdinfäücibüsmäürisämet.', array('CHARSET' => 'UTF-8'));
 
72
        $ical->addComponent($event);
 
73
        $this->assertStringEqualsFile(
 
74
            __DIR__ . '/fixtures/line-folding-5.ics',
 
75
            $ical->exportVCalendar()
 
76
        );
 
77
 
 
78
        $ical = new Horde_Icalendar();
 
79
        $event = Horde_Icalendar::newComponent('vevent', $ical);
 
80
        $event->setAttribute('UID', 'XXX');
 
81
        $event->setAttribute('DTSTART', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
82
        $event->setAttribute('DTSTAMP', array('year' => 2008, 'month' => 1, 'mday' => 1), array('VALUE' => 'DATE'));
 
83
        $description = <<<EOT
 
84
SYLVIE DAGORNE a écrit :
 
85
 
 
86
Bonjour,
 
87
 
 
88
suite à mon appel téléphonique auprès de Jacques Benzerara, il m'a renvoyé vers vous. En effet, je souhaiterais vous rencontrer car:
 
89
1°) au niveau de l'observatoire local nous devons lancer une enquête sur un suivi de cohorte à la rentrée prochaine qui concernera tous les étudiants de L1. Nous souhaiterons faire un questionnaire en ligne ce questionnaire devra être hébergé sur un serveur.
 
90
 
 
91
2°) dans le cadre de l'observatoire régional, nos partenaires nous demande également de faire des questionnaires en ligne. Nous disposons du logiciel Modalisa qui permet de le réaliser mais du point de vu technique, nous avons besoin de voir avec vous,  les difficultés et les limites d'un tel dispositif afin de voir les démarches à suivre et pouvoir évoquer tous ces problèmes techniques, je souhaiterais vous rencontrer. Merci de me précisez vos disponibilités?
 
92
...
 
93
Je serai accompagné d'un collègue pour l'observatoire local (David Le foll) et de la chargée d'études de l'observatoire régional (Amélie Gicquel) pour la partie régionale.
 
94
EOT;
 
95
        $event->setAttribute('DESCRIPTION', $description);
 
96
        $ical->addComponent($event);
 
97
        $this->assertStringEqualsFile(
 
98
            __DIR__ . '/fixtures/line-folding-6.ics',
 
99
            $ical->exportVCalendar()
 
100
        );
 
101
    }
 
102
 
 
103
    public function testEscapes()
 
104
    {
 
105
        $ical = new Horde_Icalendar();
 
106
 
 
107
        $event1 = Horde_Icalendar::newComponent('vevent', $ical);
 
108
        $event2 = Horde_Icalendar::newComponent('vevent', $ical);
 
109
 
 
110
        $event1->setAttribute('UID', '20041120-8550-innerjoin-org');
 
111
        $event1->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 3), array('VALUE' => 'DATE'));
 
112
        $event1->setAttribute('DTSTAMP', array('year' => 2004, 'month' => 11, 'mday' => 20), array('VALUE' => 'DATE'));
 
113
        $event1->setAttribute('SUMMARY', 'Escaped Comma in Description Field');
 
114
        $event1->setAttribute('DESCRIPTION', 'There is a comma (escaped with a baskslash) in this sentence and some important words after it, see anything here?');
 
115
 
 
116
        $event2->setAttribute('UID', '20041120-8549-innerjoin-org');
 
117
        $event2->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 4), array('VALUE' => 'DATE'));
 
118
        $event2->setAttribute('DTSTAMP', array('year' => 2004, 'month' => 11, 'mday' => 20), array('VALUE' => 'DATE'));
 
119
        $event2->setAttribute('SUMMARY', 'Dash (rather than Comma) in the Description Field');
 
120
        $event2->setAttribute('DESCRIPTION', 'There are important words after this dash - see anything here or have the words gone?');
 
121
 
 
122
        $ical->addComponent($event1);
 
123
        $ical->addComponent($event2);
 
124
 
 
125
        $this->assertStringEqualsFile(
 
126
            __DIR__ . '/fixtures/escapes2.ics',
 
127
            $ical->exportVCalendar()
 
128
        );
 
129
 
 
130
        $readIcal = new Horde_Icalendar();
 
131
        $readIcal->parseVCalendar($ical->exportVCalendar());
 
132
        $this->assertEquals(
 
133
            array('There is a comma (escaped with a baskslash) in this sentence and some important words after it, see anything here?'),
 
134
            $readIcal->getComponent(0)->getAttributeValues('DESCRIPTION')
 
135
        );
 
136
        $this->assertEquals(
 
137
            array('There are important words after this dash - see anything here or have the words gone?'),
 
138
            $readIcal->getComponent(1)->getAttributeValues('DESCRIPTION')
 
139
        );
 
140
    }
 
141
 
 
142
    public function testQuotedParameters()
 
143
    {
 
144
        $ical = new Horde_Icalendar();
 
145
        $event1 = Horde_Icalendar::newComponent('vevent', $ical);
 
146
        $event1->setAttribute('UID', '20041120-8550-innerjoin-org');
 
147
        $event1->setAttribute('DTSTART', array('year' => 2005, 'month' => 5, 'mday' => 3), array('VALUE' => 'DATE'));
 
148
        $event1->setAttribute('DTSTAMP', array('year' => 2004, 'month' => 11, 'mday' => 20), array('VALUE' => 'DATE'));
 
149
        $event1->setAttribute('SUMMARY', 'Escaped Comma in Description Field');
 
150
        $event1->setAttribute('DESCRIPTION', 'There is a comma (escaped with a baskslash) in this sentence and some important words after it, see anything here?');
 
151
        $event1->setAttribute('ORGANIZER', 'mailto:mueller@example.org', array('CN' => "Klä,rc\"hen;\n Mül:ler"));
 
152
        $ical->addComponent($event1);
 
153
        $this->assertStringEqualsFile(
 
154
            __DIR__ . '/fixtures/quoted-params.ics',
 
155
            $ical->exportVCalendar()
 
156
        );
 
157
    }
 
158
}