group_by = array ('sales_stage', 'user_name'); $sugarChartObject->data_set = $this->getDataSet(); $sugarChartObject->base_url = array ('module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search'); $sugarChartObject->url_params = array (); $sugarChartObject->is_currency = true; // we have 5 users $sugarChartObject->super_set = array ('will', 'max', 'sarah', 'sally', 'chris'); $this->sugarChartObject = $sugarChartObject; } public function tearDown() { SugarTestUserUtilities::removeAllCreatedAnonymousUsers(); unset($GLOBALS['current_user']); } public function getDataSet() { return array ( array ( 'sales_stage' => 'Proposal/Price Quote', 'user_name' => 'max', 'assigned_user_id' => 'seed_max_id', 'opp_count' => '1', 'total' => '50', 'key' => 'Proposal/Price Quote', 'value' => 'Proposal/Price Quote', ), array ( 'sales_stage' => 'Proposal/Price Quote', 'user_name' => 'sally', 'assigned_user_id' => 'seed_sally_id', 'opp_count' => '2', 'total' => '75', 'key' => 'Proposal/Price Quote', 'value' => 'Proposal/Price Quote', ), ); } /** * We check, that groups with NULL value remain their order in subgroups tag and won't fall down under not null valued groups. * This way we guarantee that links will be put correctly to each user in whole user list (will, max, etc.). */ public function testCorrectXml() { $actual = $this->sugarChartObject->xmlDataGenericChart(); $expected = $this->compareXml(); $order = array("\r\n", "\n", "\r", "\t"); $replace = ""; // remove all break lines and spaces and tabs $expected = str_replace($order, $replace, $expected); $actual = str_replace($order, $replace, $actual); $this->assertEquals($expected, $actual); } /** * @return xml string */ public function compareXml() { $max = 50; $sally = 75; $total = $max + $sally; $max = $this->convertCurrency($max); $sally = $this->convertCurrency($sally); $total = $this->convertCurrency($total); return " Proposal/Price Quote {$total->subAmount} index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote will NULL index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote max {$max->subAmount} index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote&assigned_user_id[]=seed_max_id sarah NULL index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote sally {$sally->subAmount} index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote&assigned_user_id[]=seed_sally_id chris NULL index.php?module=Opportunities&action=index&query=true&searchFormTab=advanced_search&sales_stage=Proposal%2FPrice+Quote "; } public function convertCurrency($value) { $sub_amount = $this->sugarChartObject->formatNumber($this->sugarChartObject->convertCurrency($value)); $sub_amount_formatted = $this->sugarChartObject->currency_symbol . $sub_amount . 'K'; $sub_amount = $this->sugarChartObject->convertCurrency($value); $return = new stdClass(); $return->subAmount = $sub_amount; $return->subAmountFormatted = $sub_amount_formatted; return $return; } }