2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
37 require_once('include/SugarCharts/SugarChart.php');
39 * Created: Sep 28, 2011
41 class Bug44696Test extends Sugar_PHPUnit_Framework_TestCase
43 public $sugarChartObject;
45 public function setUp()
47 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
48 $sugarChartObject = new SugarChart();
49 $sugarChartObject->group_by = array ('sales_stage', 'user_name');
50 $sugarChartObject->data_set = $this->getDataSet();
51 $sugarChartObject->base_url = array ('module' => 'Opportunities',
54 'searchFormTab' => 'advanced_search');
55 $sugarChartObject->url_params = array ();
56 $sugarChartObject->is_currency = true;
58 $sugarChartObject->super_set = array ('will', 'max', 'sarah', 'sally', 'chris');
59 $this->sugarChartObject = $sugarChartObject;
62 public function tearDown()
64 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
65 unset($GLOBALS['current_user']);
68 public function getDataSet() {
71 'sales_stage' => 'Proposal/Price Quote',
73 'assigned_user_id' => 'seed_max_id',
76 'key' => 'Proposal/Price Quote',
77 'value' => 'Proposal/Price Quote',
80 'sales_stage' => 'Proposal/Price Quote',
81 'user_name' => 'sally',
82 'assigned_user_id' => 'seed_sally_id',
85 'key' => 'Proposal/Price Quote',
86 'value' => 'Proposal/Price Quote',
92 * We check, that groups with NULL value remain their order in subgroups tag and won't fall down under not null valued groups.
93 * This way we guarantee that links will be put correctly to each user in whole user list (will, max, etc.).
95 public function testCorrectXml()
97 $actual = $this->sugarChartObject->xmlDataGenericChart();
98 $expected = $this->compareXml();
99 $order = array("\r\n", "\n", "\r", "\t");
101 // remove all break lines and spaces and tabs
102 $expected = str_replace($order, $replace, $expected);
103 $actual = str_replace($order, $replace, $actual);
104 $this->assertEquals($expected, $actual);
110 public function compareXml()
114 $total = $max + $sally;
115 $max = $this->convertCurrency($max);
116 $sally = $this->convertCurrency($sally);
117 $total = $this->convertCurrency($total);
120 <title>Proposal/Price Quote</title>
121 <value>{$total->subAmount}</value>
122 <label>{$total->subAmountFormatted}</label>
123 <link>index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote</link>
129 <link>index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote</link>
133 <value>{$max->subAmount}</value>
134 <label>{$max->subAmountFormatted}</label>
135 <link>index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote&assigned_user_id[]=seed_max_id</link>
141 <link>index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote</link>
145 <value>{$sally->subAmount}</value>
146 <label>{$sally->subAmountFormatted}</label>
147 <link>index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote&assigned_user_id[]=seed_sally_id</link>
153 <link>index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote</link>
155 </subgroups></group>";
158 public function convertCurrency($value) {
159 $sub_amount = $this->sugarChartObject->formatNumber($this->sugarChartObject->convertCurrency($value));
160 $sub_amount_formatted = $this->sugarChartObject->currency_symbol . $sub_amount . 'K';
161 $sub_amount = $this->sugarChartObject->convertCurrency($value);
162 $return = new stdClass();
163 $return->subAmount = $sub_amount;
164 $return->subAmountFormatted = $sub_amount_formatted;