]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/soap/Bug51182Test.php
Release 6.5.11
[Github/sugarcrm.git] / tests / soap / Bug51182Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
5  * 
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.
12  * 
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
16  * details.
17  * 
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
21  * 02110-1301 USA.
22  * 
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.
25  * 
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.
29  * 
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  ********************************************************************************/
36
37
38 require_once('tests/service/SOAPTestCase.php');
39 require_once('modules/Reports/Report.php');
40
41 /**
42  * Bug #51182
43  * Test if get_entry() properly returns details for "Summary With Details" report
44  *
45  * @author avucinic@sugarcrm.com
46  * @ticked 51182
47  */
48 class Bug51182Test extends SOAPTestCase
49 {
50
51     private $_report;
52
53     public function setUp()
54     {
55         $this->_soapURL = $GLOBALS['sugar_config']['site_url'].'/soap.php';
56
57         parent::setUp();
58
59         SugarTestHelper::setUp('beanFiles');
60         SugarTestHelper::setUp('beanList');
61         $this->user = SugarTestHelper::setUp('current_user', array(true, true));
62
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");
69     }
70
71     public function tearDown()
72     {
73         $GLOBALS['db']->query("DELETE FROM saved_reports WHERE id = '{$this->_report->saved_report->id}'");
74         SugarTestOpportunityUtilities::removeAllCreatedOpportunities();
75         SugarTestHelper::tearDown();
76     }
77
78     // Test if the returned data is proper
79     public function testSummaryReportWithDetails()
80     {
81         $this->_login();
82
83         // Setup call
84         $client = array(
85             'session'       => $this->_sessionId,
86             'module_name'   => 'Reports',
87             'id'            => $this->_report->saved_report->id,
88             'select_fields' => array(),
89         );
90
91         // Call get_entry on saved report
92         $result = $this->_soapClient->call('get_entry', $client);
93
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'.");
99     }
100
101 }
102