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 // Create and save summary with details report on opportunities, filtered by id of the above created opportunity
66 $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"}}}');
67 $_REQUEST['assigned_user_id'] = $GLOBALS['current_user']->id;
68 $this->_report->save("testSummaryReportWithDetails");
71 public function tearDown()
73 $GLOBALS['db']->query("DELETE FROM saved_reports WHERE id = '{$this->_report->saved_report->id}'");
74 SugarTestOpportunityUtilities::removeAllCreatedOpportunities();
75 SugarTestHelper::tearDown();
78 // Test if the returned data is proper
79 public function testSummaryReportWithDetails()
85 'session' => $this->_sessionId,
86 'module_name' => 'Reports',
87 'id' => $this->_report->saved_report->id,
88 'select_fields' => array(),
91 // Call get_entry on saved report
92 $result = $this->_soapClient->call('get_entry', $client);
94 // Check if the soap call returned the details rows
95 $this->assertNotEmpty($result['entry_list'], "Report shouldn't be empty.");
96 $this->assertNotEmpty($result['entry_list'][0]['details'], "Summary Report Details shouldn't be empty.");
97 // Check if the returned headers for the details have the correct type
98 $this->assertEquals($result['field_list'][2]['type'], 'details', "Type of detail columns headers should be 'details'.");