]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/vCals/Bug62943Test.php
Release 6.5.15
[Github/sugarcrm.git] / tests / modules / vCals / Bug62943Test.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 #62943
20  * GOTO MEETING ceation in SugarCRM does not dispay goto info in attachment
21  *
22  * @author bsitnikovski@sugarcrm.com
23  * @ticket 62943
24  */
25 class Bug62943Test extends Sugar_PHPUnit_Framework_TestCase
26 {
27
28         public function setUp()
29         {
30                 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
31                 $GLOBALS['current_user']->full_name = "Boro Sitnikovski";
32                 $GLOBALS['current_user']->email1 = "bsitnikovski@sugarcrm.com";
33         }
34
35         public function tearDown()
36         {
37                 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
38                 unset($GLOBALS['current_user']);
39         }
40
41         public function testiCalEscaping()
42         {
43                 $res = vCal::get_ical_event($this->_getDummyBean("http://www.sugarcrm.com/"), $GLOBALS['current_user']);
44
45                 $desc = $this->_grabiCalField($res, "DESCRIPTION");
46
47                 // Test to see if there are two newlines after url for description
48                 $this->assertContains("http://www.sugarcrm.com/\\n\\n", $desc);
49
50                 // Test description encoding
51                 $this->assertContains("\\,", $desc);
52                 $this->assertContains("\\n", $desc);
53                 $this->assertContains("\\\\", $desc);
54                 $this->assertContains("\\;", $desc);
55
56                 $location = $this->_grabiCalField($res, "LOCATION");
57
58                 // Test location encoding
59                 $this->assertContains("\\,", $location);
60                 $this->assertContains("\\;", $location);
61         }
62
63         public function testiCalEmptyJoinURL()
64         {
65                 $res = vCal::get_ical_event($this->_getDummyBean(), $GLOBALS['current_user']);
66
67                 $desc = $this->_grabiCalField($res, "DESCRIPTION");
68
69                 // Test to see if there are no newlines for empty url for description
70                 $this->assertNotContains("\\n\\n", $desc);
71         }
72
73         private function _grabiCalField($iCal, $field)
74         {
75                 $ret = strstr($iCal, $field . ':');
76                 $ret = substr($ret, 0, strpos($ret, "\n"));
77                 return $ret;
78         }
79
80         private function _getDummyBean($join_url = "")
81         {
82                 $bean = new SugarBean();
83                 $bean->id = 123;
84                 $bean->date_start = $bean->date_end = $GLOBALS['timedate']->nowDb();
85                 $bean->name = "Dummy Bean";
86                 $bean->location = "Sugar, Cupertino; Sugar, EMEA";
87                 $bean->join_url = $join_url;
88                 $bean->description = "Hello, this is a dummy description.\nIt contains newlines, backslash \\ semicolon ; and commas";
89                 return $bean;
90         }
91
92 }