]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/ModuleBuilder/Bug49964Test.php
Release 6.5.10
[Github/sugarcrm.git] / tests / modules / ModuleBuilder / Bug49964Test.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 require_once 'modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php';
38
39 /**
40  * Bug #49964
41  *
42  *      Save & Deploy of Meetings dashlet makes non-sortable columns sortable, causing SQL Error
43  *
44  * @ticket 49964
45  * @author arymarchik@sugarcrm.com
46  */
47 class Bug49964Test extends Sugar_PHPUnit_Framework_TestCase
48 {
49     private $_metadata = array(
50         'set_complete' => array(
51             'width' => '1',
52             'label'    => 'LBL_LIST_CLOSE',
53             'default'  => true,
54             'sortable' => false,
55             'related_fields' => array(
56                 'status'
57             )
58         ),
59         'join_meeting' => array(
60             'width'    => '1',
61             'label'    => 'LBL_LIST_JOIN_MEETING',
62             'default'  => true,
63             'sortable' => false,
64             'noHeader' => true,
65             'related_fields' => array(
66                 'host_url'
67             )
68         ),
69         'name' => array(
70             'width'   => '40',
71             'label'   => 'LBL_SUBJECT',
72             'link'    => true,
73             'default' => true
74         ),
75         'parent_name' => array(
76             'width' => '29',
77             'label' => 'LBL_LIST_RELATED_TO',
78             'sortable' => false,
79             'dynamic_module' => 'PARENT_TYPE',
80             'link' => true,
81             'id' => 'PARENT_ID',
82             'ACLTag' => 'PARENT',
83             'related_fields' => array(
84                 'parent_id',
85                 'parent_type'
86             ),
87             'default' => true
88         ),
89         'duration' => array(
90             'width'    => '15',
91             'label'    => 'LBL_DURATION',
92             'sortable' => false,
93             'related_fields' => array(
94                 'duration_hours',
95                 'duration_minutes'
96             )
97         ),
98         'date_start' => array(
99             'width'   => '15',
100             'label'   => 'LBL_DATE',
101             'default' => true,
102             'related_fields' => array(
103                 'time_start'
104             )
105         ),
106         'set_accept_links'=> array(
107             'width'    => '10',
108             'label'    => 'LBL_ACCEPT_THIS',
109             'sortable' => false,
110             'default' => true,
111             'related_fields' => array(
112                 'status'
113             )
114         ),
115         'status' => array(
116             'width'   => '8',
117             'label'   => 'LBL_STATUS'
118         ),
119         'type' => array(
120             'width'   => '8',
121             'label'   => 'LBL_TYPE'
122         ),
123         'date_entered' => array(
124             'width'   => '15',
125             'label'   => 'LBL_DATE_ENTERED'
126         ),
127         'date_modified' => array(
128             'width'   => '15',
129             'label'   => 'LBL_DATE_MODIFIED'
130         ),
131         'created_by' => array(
132             'width'   => '8',
133             'label'   => 'LBL_CREATED'
134         ),
135         'assigned_user_name' => array(
136             'width'   => '8',
137             'label'   => 'LBL_LIST_ASSIGNED_USER'
138         ),
139         'team_name' => array(
140             'width'   => '15',
141             'label'   => 'LBL_LIST_TEAM'
142         )
143     );
144
145     public function setUp()
146     {
147         global $beanList, $beanFiles;
148         require('include/modules.php');
149
150         $_REQUEST = array();
151         $_REQUEST['view'] = 'dashlet';
152         $_REQUEST['view_module'] = 'Meetings';
153         $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
154     }
155
156     public function tearDown()
157     {
158         $_REQUEST = array();
159         unset($GLOBALS['app_list_strings']);
160         unset($GLOBALS['beanList']);
161         unset($GLOBALS['beanFiles']);
162     }
163
164     /**
165      * Trying to load default metadata and compare it with origin after conversion
166      * @group 49964
167      */
168     public function testHandleSave()
169     {
170         $mock = $this->getMockBuilder('DeployedMetaDataImplementation')
171                 ->disableOriginalConstructor()
172                 ->setMethods(array('_loadFromFile'))
173                 ->getMock();
174         $mock->expects($this->any())
175             ->method('_loadFromFile')
176             ->will($this->onConsecutiveCalls(null, null, null, null, $this->_metadata));
177         $mock->__construct($_REQUEST['view'], $_REQUEST['view_module']);
178         $this->assertEquals($this->_metadata, $mock->getViewdefs());
179     }
180 }