]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/vCals/Bug62943Test.php
Release 6.5.16
[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 testiCalNewline()
42         {
43                 $res = vCal::get_ical_event($this->_getDummyBean("http://www.sugarcrm.com/"), $GLOBALS['current_user']);
44
45         $desc = $this->grabiCalField($res, "DESCRIPTION");
46         // Test to see if there are two newlines after url for description
47         $this->assertContains("http://www.sugarcrm.com/\r\n\r\n", $desc);
48         }
49
50         public function testiCalEmptyJoinURL()
51         {
52                 $res = vCal::get_ical_event($this->_getDummyBean(), $GLOBALS['current_user']);
53
54         $desc = $this->grabiCalField($res, "DESCRIPTION");
55
56                 // Test to see if there are no newlines for empty url for description
57                 $this->assertNotContains("\\n\\n", $desc);
58         }
59
60     private function grabiCalField($iCal, $field)
61     {
62         $ical_arr = vCal::create_ical_array_from_string($iCal);
63
64         foreach ($ical_arr as $ical_val) {
65             if ($ical_val[0] == $field) {
66                 return $ical_val[1];
67             }
68         }
69
70         return "";
71     }
72
73         private function _getDummyBean($join_url = "")
74         {
75                 $bean = new SugarBean();
76                 $bean->id = 123;
77                 $bean->date_start = $bean->date_end = $GLOBALS['timedate']->nowDb();
78                 $bean->name = "Dummy Bean";
79                 $bean->location = "Sugar, Cupertino; Sugar, EMEA";
80                 $bean->join_url = $join_url;
81                 $bean->description = "Hello, this is a dummy description.\nIt contains newlines, backslash \\ semicolon ; and commas";
82                 return $bean;
83         }
84
85 }