2.0
-//hacksw/handcal//NONSGML v1.0//EN
';
$this->assertEquals($compare, $out);
}
function testWindowsLineEndings() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'END:VCALENDAR');
$out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\r\n",$in));
$compare = '
2.0
-//hacksw/handcal//NONSGML v1.0//EN
';
$this->assertEquals($compare, $out);
}
function testEvent() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'BEGIN:VEVENT',
'SUMMARY:meeting',
'END:VEVENT',
'END:VCALENDAR');
$out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in));
$compare = '
2.0
-//hacksw/handcal//NONSGML v1.0//EN
meeting
';
$this->assertEquals($compare, $out);
}
function testLineFolding() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'BEGIN:VEVENT',
'SUMMARY:mee',
' ting',
'END:VEVENT',
'END:VCALENDAR');
$out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in));
$compare = '
2.0
-//hacksw/handcal//NONSGML v1.0//EN
meeting
';
$this->assertEquals($compare, $out);
}
function testAttribute() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'BEGIN:VEVENT',
'SUMMARY:meeting',
'X-SABRE;att1=val1:This is the property content',
'END:VEVENT',
'END:VCALENDAR');
$out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in));
$compare = '
2.0
-//hacksw/handcal//NONSGML v1.0//EN
meeting
This is the property content
';
$this->assertEquals($compare, $out);
}
function testAttribute2() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'BEGIN:VEVENT',
'SUMMARY;LANGUAGE=nl-NL:meeting',
'X-SABRE;att1=val1;att2=val2:This is the property content',
'END:VEVENT',
'END:VCALENDAR');
$out = Sabre_CalDAV_ICalendarUtil::toXCal(implode("\n",$in));
$compare = '
2.0
-//hacksw/handcal//NONSGML v1.0//EN
meeting
This is the property content
';
$this->assertEquals($compare, $out);
}
function testValidateICalendarObjectValid() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'BEGIN:VEVENT',
'SUMMARY;LANGUAGE=nl-NL:meeting',
'X-SABRE;att1=val1;att2=val2:This is the property content',
'END:VEVENT',
'END:VCALENDAR');
$this->assertTrue(Sabre_CalDAV_ICalendarUtil::validateICalendarObject(implode("\n",$in),array('VEVENT')));
}
/**
* @expectedException Sabre_CalDAV_Exception_InvalidICalendarObject
* @depends testValidateICalendarObjectValid
*/
function testValidateICalendarObjectNoData() {
Sabre_CalDAV_ICalendarUtil::validateICalendarObject('',array('VEVENT'));
}
/**
* @expectedException Sabre_CalDAV_Exception_InvalidICalendarObject
* @depends testValidateICalendarObjectValid
*/
function testValidateICalendarObjectWrongObject() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'BEGIN:VEVENT',
'SUMMARY;LANGUAGE=nl-NL:meeting',
'X-SABRE;att1=val1;att2=val2:This is the property content',
'END:VEVENT',
'END:VCALENDAR');
Sabre_CalDAV_ICalendarUtil::validateICalendarObject(implode("\n",$in),array('VTODO'));
}
/**
* @expectedException Sabre_CalDAV_Exception_InvalidICalendarObject
* @depends testValidateICalendarObjectValid
*/
function testValidateICalendarObjectHasMethodProperty() {
$in = array(
'BEGIN:VCALENDAR',
'VERSION:2.0',
'METHOD:blabla',
'PRODID:-//hacksw/handcal//NONSGML v1.0//EN',
'BEGIN:VEVENT',
'SUMMARY;LANGUAGE=nl-NL:meeting',
'X-SABRE;att1=val1;att2=val2:This is the property content',
'END:VEVENT',
'END:VCALENDAR');
Sabre_CalDAV_ICalendarUtil::validateICalendarObject(implode("\n",$in),array('VEVENT'));
}
}