]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/soap/Bug51182Test.php
Release 6.5.16
[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         $opportunity->opportunity_type = 'New Business';
66         $opportunity->sales_stage = 'Prospecting';
67         $opportunity->save();
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");
72     }
73
74     public function tearDown()
75     {
76         $GLOBALS['db']->query("DELETE FROM saved_reports WHERE id = '{$this->report->saved_report->id}'");
77         SugarTestOpportunityUtilities::removeAllCreatedOpportunities();
78         SugarTestHelper::tearDown();
79     }
80
81     // Test if the returned data is proper
82     public function testSummaryReportWithDetails()
83     {
84         $this->_login();
85
86         // Setup call
87         $client = array(
88             'session'       => $this->_sessionId,
89             'module_name'   => 'Reports',
90             'id'            => $this->report->saved_report->id,
91             'select_fields' => array(),
92         );
93
94         // Call get_entry on saved report
95         $result = $this->_soapClient->call('get_entry', $client);
96
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
101         $this->assertEquals(
102             $result['field_list'][2]['type'],
103             'header',
104             "Type of detail column headers should be 'header'."
105         );
106         $this->assertEquals(
107             $result['field_list'][0]['type'],
108             'groupheader',
109             "Type of group column headers should be 'groupheader'."
110         );
111     }
112 }