2 /*********************************************************************************
3 * By installing or using this file, you are confirming on behalf of the entity
4 * subscribed to the SugarCRM Inc. product ("Company") that Company is bound by
5 * the SugarCRM Inc. Master Subscription Agreement (“MSA”), which is viewable at:
6 * http://www.sugarcrm.com/master-subscription-agreement
8 * If Company is not bound by the MSA, then by installing or using this file
9 * you are agreeing unconditionally that Company will be bound by the MSA and
10 * certifying that you have authority to bind Company accordingly.
12 * Copyright (C) 2004-2013 SugarCRM Inc. All rights reserved.
13 ********************************************************************************/
16 require_once 'modules/vCals/vCal.php';
20 * iCal Should Respect RFC 5545
22 * @author bsitnikovski@sugarcrm.com
25 class Bug64061Test extends Sugar_PHPUnit_Framework_TestCase
29 * Test an empty string and see if it gets added
32 public function testLineBreaks()
34 // this field should not be added by fold_ical_lines
35 // and it is already checked because $icalstring does not contain it
37 $icalarray[] = array("TESTLINEBREAKS", "------------------------75characters------------------------0");
38 $res = vCal::create_ical_string_from_array($icalarray);
40 $icalstring = "TESTLINEBREAKS:------------------------75characters------------------------\r\n\t0\r\n";
41 $this->assertEquals($icalstring, $res);
45 * Test the function create_ical_string_from_array()
47 * @dataProvider iCalProvider
49 public function testiCalStringFromArray($icalarray, $icalstring)
51 $res = vCal::create_ical_string_from_array($icalarray);
52 $this->assertEquals($icalstring, $res);
56 * Test the function create_ical_array_from_string()
58 * @dataProvider iCalProvider
60 public function testiCalArrayFromString($icalarray, $icalstring)
62 $res = vCal::create_ical_array_from_string($icalstring);
63 $this->assertEquals($icalarray, $res);
66 public function iCalProvider()
68 $ical_array = array();
69 $ical_array[] = array("BEGIN", "VCALENDAR");
70 $ical_array[] = array("VERSION", "2.0");
71 $ical_array[] = array("PRODID", "-//SugarCRM//SugarCRM Calendar//EN");
72 $ical_array[] = array("BEGIN", "VEVENT");
73 $ical_array[] = array("UID", "123");
74 $ical_array[] = array("ORGANIZED;CN=Boro Sitnikovski", "bsitnikovski@sugarcrm.com");
75 $ical_array[] = array("SUMMARY", "Dummy Bean");
76 $ical_array[] = array("LOCATION", "Sugar, Cupertino; Sugar, EMEA");
77 $ical_array[] = array("DESCRIPTION", "Hello, this is a dummy description.\nIt contains newlines, " .
78 "backslash \ semicolon ; and commas. This line should also contain more than 75 characters.");
79 $ical_array[] = array("END", "VEVENT");
80 $ical_array[] = array("END", "VCALENDAR");
82 $ical_string = "BEGIN:VCALENDAR\r\n" .
84 "PRODID:-//SugarCRM//SugarCRM Calendar//EN\r\n" .
87 "ORGANIZED;CN=Boro Sitnikovski:bsitnikovski@sugarcrm.com\r\n" .
88 "SUMMARY:Dummy Bean\r\n" .
89 "LOCATION:Sugar\\, Cupertino\\; Sugar\\, EMEA\r\n" .
90 "DESCRIPTION:Hello\\, this is a dummy description.\\nIt contains newlines\\, ba\r\n" .
91 "\tckslash \\\\ semicolon \\; and commas. This line should also contain more tha\r\n" .
92 "\tn 75 characters.\r\n" .
96 return array(array($ical_array, $ical_string));