2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 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 ********************************************************************************/
38 require_once('tests/service/SOAPTestCase.php');
39 require_once('modules/Reports/Report.php');
43 * Test if get_entry() properly returns details for "Summary With Details" report
45 * @author avucinic@sugarcrm.com
48 class Bug51182Test extends SOAPTestCase
53 public function setUp()
55 $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php';
59 SugarTestHelper::setUp('beanFiles');
60 SugarTestHelper::setUp('beanList');
61 $this->user = SugarTestHelper::setUp('current_user', array(true, true));
63 // Create an opportunity for the report
64 $opportunity = SugarTestOpportunityUtilities::createOpportunity();
65 $opportunity->opportunity_type = 'New Business';
66 $opportunity->sales_stage = 'Prospecting';
68 // Create and save summary with details report on opportunities, filtered by id of the above created opportunity
69 $this->report = new Report('{"display_columns":[{"name":"name","label":"Opportunity Name","table_key":"self"},{"name":"sales_stage","label":"Sales Stage","table_key":"self"}],"module":"Opportunities","group_defs":[{"name":"opportunity_type","label":"Type","table_key":"self","type":"enum","force_label":"Type"}],"summary_columns":[{"name":"opportunity_type","label":"Type","table_key":"self"}],"report_name":"Opp by type","chart_type":"none","do_round":1,"chart_description":"","numerical_chart_column":"","numerical_chart_column_type":"","assigned_user_id":"1","report_type":"summary","full_table_list":{"self":{"value":"Opportunities","module":"Opportunities","label":"Opportunities"}},"filters_def":{"Filter_1":{"0":{"name":"id","table_key":"self","qualifier_name":"is","input_name0":"' . $opportunity->id . '","input_name1":"' . $opportunity->name . '","column_name":"self:id","id":"rowid0"},"operator":"AND"}}}');
70 $_REQUEST['assigned_user_id'] = $GLOBALS['current_user']->id;
71 $this->report->save("testSummaryReportWithDetails");
74 public function tearDown()
76 $GLOBALS['db']->query("DELETE FROM saved_reports WHERE id = '{$this->report->saved_report->id}'");
77 SugarTestOpportunityUtilities::removeAllCreatedOpportunities();
78 SugarTestHelper::tearDown();
81 // Test if the returned data is proper
82 public function testSummaryReportWithDetails()
88 'session' => $this->_sessionId,
89 'module_name' => 'Reports',
90 'id' => $this->report->saved_report->id,
91 'select_fields' => array(),
94 // Call get_entry on saved report
95 $result = $this->_soapClient->call('get_entry', $client);
97 // Check if the soap call returned the details rows
98 $this->assertNotEmpty($result['entry_list'], "Report shouldn't be empty.");
99 $this->assertEquals($result['entry_list'][1]['id'], '0.0', "Summary Report Details row shouldn't be empty.");
100 // Check if the returned headers for the details have the correct type
102 $result['field_list'][2]['type'],
104 "Type of detail column headers should be 'header'."
107 $result['field_list'][0]['type'],
109 "Type of group column headers should be 'groupheader'."