]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/vCals/Bug64061Test.php
Release 6.5.16
[Github/sugarcrm.git] / tests / modules / vCals / Bug64061Test.php
1 <?php
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
7  *
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.
11  *
12  * Copyright (C) 2004-2013 SugarCRM Inc.  All rights reserved.
13  ********************************************************************************/
14
15
16 require_once 'modules/vCals/vCal.php';
17
18 /**
19  * Bug #64061
20  * iCal Should Respect RFC 5545
21  *
22  * @author bsitnikovski@sugarcrm.com
23  * @ticket 64061
24  */
25 class Bug64061Test extends Sugar_PHPUnit_Framework_TestCase
26 {
27
28     /**
29      * Test an empty string and see if it gets added
30      *
31      */
32     public function testLineBreaks()
33     {
34         // this field should not be added by fold_ical_lines
35         // and it is already checked because $icalstring does not contain it
36         $icalarray = array();
37         $icalarray[] = array("TESTLINEBREAKS", "------------------------75characters------------------------0");
38         $res = vCal::create_ical_string_from_array($icalarray);
39
40         $icalstring = "TESTLINEBREAKS:------------------------75characters------------------------\r\n\t0\r\n";
41         $this->assertEquals($icalstring, $res);
42     }
43
44     /**
45      * Test the function create_ical_string_from_array()
46      *
47      * @dataProvider iCalProvider
48      */
49     public function testiCalStringFromArray($icalarray, $icalstring)
50     {
51         $res = vCal::create_ical_string_from_array($icalarray);
52         $this->assertEquals($icalstring, $res);
53     }
54
55     /**
56      * Test the function create_ical_array_from_string()
57      *
58      * @dataProvider iCalProvider
59      */
60     public function testiCalArrayFromString($icalarray, $icalstring)
61     {
62         $res = vCal::create_ical_array_from_string($icalstring);
63         $this->assertEquals($icalarray, $res);
64     }
65
66     public function iCalProvider()
67     {
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");
81
82         $ical_string = "BEGIN:VCALENDAR\r\n" .
83             "VERSION:2.0\r\n" .
84             "PRODID:-//SugarCRM//SugarCRM Calendar//EN\r\n" .
85             "BEGIN:VEVENT\r\n" .
86             "UID:123\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" .
93             "END:VEVENT\r\n" .
94             "END:VCALENDAR\r\n";
95
96         return array(array($ical_array, $ical_string));
97     }
98 }