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 * GOTO MEETING ceation in SugarCRM does not dispay goto info in attachment
22 * @author bsitnikovski@sugarcrm.com
25 class Bug62943Test extends Sugar_PHPUnit_Framework_TestCase
28 public function setUp()
30 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
31 $GLOBALS['current_user']->full_name = "Boro Sitnikovski";
32 $GLOBALS['current_user']->email1 = "bsitnikovski@sugarcrm.com";
35 public function tearDown()
37 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
38 unset($GLOBALS['current_user']);
41 public function testiCalEscaping()
43 $res = vCal::get_ical_event($this->_getDummyBean("http://www.sugarcrm.com/"), $GLOBALS['current_user']);
45 $desc = $this->_grabiCalField($res, "DESCRIPTION");
47 // Test to see if there are two newlines after url for description
48 $this->assertContains("http://www.sugarcrm.com/\\n\\n", $desc);
50 // Test description encoding
51 $this->assertContains("\\,", $desc);
52 $this->assertContains("\\n", $desc);
53 $this->assertContains("\\\\", $desc);
54 $this->assertContains("\\;", $desc);
56 $location = $this->_grabiCalField($res, "LOCATION");
58 // Test location encoding
59 $this->assertContains("\\,", $location);
60 $this->assertContains("\\;", $location);
63 public function testiCalEmptyJoinURL()
65 $res = vCal::get_ical_event($this->_getDummyBean(), $GLOBALS['current_user']);
67 $desc = $this->_grabiCalField($res, "DESCRIPTION");
69 // Test to see if there are no newlines for empty url for description
70 $this->assertNotContains("\\n\\n", $desc);
73 private function _grabiCalField($iCal, $field)
75 $ret = strstr($iCal, $field . ':');
76 $ret = substr($ret, 0, strpos($ret, "\n"));
80 private function _getDummyBean($join_url = "")
82 $bean = new SugarBean();
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";