]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Calendar/Bug57299Test.php
Release 6.5.9
[Github/sugarcrm.git] / tests / modules / Calendar / Bug57299Test.php
1 <?php
2
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38
39 require_once ('modules/Meetings/MeetingFormBase.php');
40
41 /**
42  * Bug #57299
43  *
44  * Calendar  |  Meetings with status held are not displaying in the Calendar
45  * @ticket 57299
46  * @author imatsiushyna@sugarcrm.com
47  */
48
49 class Bug57299Test extends Sugar_PHPUnit_Framework_OutputTestCase
50 {
51     /**
52      * @var FormBase
53      */
54     protected $formBase = null;
55
56     /**
57      * @var Bean
58      */
59     protected $bean = null;
60
61     /**
62      * @var module name
63      */
64     protected $name = 'Meetings';
65
66     /**
67      * @var User
68      */
69     protected $user = null;
70
71     public function setUp()
72     {
73         SugarTestHelper::setUp('beanList');
74         SugarTestHelper::setUp('beanFiles');
75         SugarTestHelper::setUp('current_user', array(true, 1));
76         SugarTestHelper::setUp('mod_strings', array($this->name));
77
78         $this->user = $GLOBALS['current_user'];
79
80         $this->user->setPreference('datef', 'm/d/Y');
81         $this->user->setPreference('timef', 'h:ia');
82         $this->user->setPreference('timezone', 'UTC');
83
84     }
85
86     public function tearDown()
87     {
88         $_POST = array();
89
90         $this->bean->db->query("DELETE FROM meetings WHERE id = '". $this->bean->id ."'");
91         $this->bean->db->query("DELETE FROM {$this->bean->rel_users_table} WHERE meeting_id = '". $this->bean->id ."'");
92
93         parent::tearDown();
94         SugarTestHelper::tearDown();
95     }
96
97     public function getPostData()
98     {
99         return array(
100             'module' => 'Calendar',
101             'name' => 'Bug57299_'.time(),
102             'current_module' => $this->name,
103             'record' => '',
104             'user_invitees' => '1',
105             'contact_invitees' => '',
106             'lead_invitees' => '',
107             'send_invites' => '',
108             'edit_all_recurrences' => true,
109             'repeat_parent_id' => '',
110             'repeat_type' => '',
111             'repeat_interval' => '',
112             'repeat_count' => '',
113             'repeat_until' => '',
114             'repeat_dow' => '',
115             'appttype' => $this->name,
116             'type' => 'Sugar',
117             'date_start' => '11/25/2012 12:00pm',
118             'parent_type' => 'Accounts',
119             'parent_name' => '',
120             'parent_id' => '',
121             'date_end' => '11/25/2012 12:15pm',
122             'location' => '',
123             'duration' => 900,
124             'duration_hours' => 0,
125             'duration_minutes' => 15,
126             'reminder_checked' => 1,
127             'reminder_time' => 1800,
128             'email_reminder_checked' => 0,
129             'email_reminder_time' => 60,
130             'assigned_user_name' => 'Administrator',
131             'assigned_user_id' => 1,
132             'update_fields_team_name_collection' => '',
133             'team_name_new_on_update' => false,
134             'team_name_allow_update' => '',
135             'team_name_allow_new' => true,
136             'team_name' => 'team_name',
137             'team_name_field' => 'team_name_table',
138             'arrow_team_name' => 'hide',
139             'team_name_collection_0' => 'Global',
140             'id_team_name_collection_0' => 1,
141             'primary_team_name_collection' => 0,
142             'description' => '',
143         );
144     }
145
146     /**
147      * providerData
148      *
149      * @return Array values for testing
150      */
151     public function providerData()
152     {
153         return array(
154             array('Held', true),
155             array('Held', false),
156         );
157     }
158
159     /**
160      * @group 57299
161      * Test that new Meeting created from module Calendar save in database correctly
162      *
163      * @dataProvider providerData
164      * @return void
165      */
166     public function testDisplaysMeetingWithStatusHeldInCalendar($status, $return_module)
167     {
168         $_POST = $this->getPostData();
169         $_POST['status'] = $status;
170         $_POST['return_module'] = ($return_module) ? 'Calendar' : '';
171         $_REQUEST = $_POST;
172
173         $this->formBase = new MeetingFormBase();
174         $this->bean = $this->formBase->handleSave('', false, false);
175
176         $sql = "SELECT * FROM {$this->bean->rel_users_table} WHERE meeting_id = '". $this->bean->id . "'";
177         $result = $this->bean->db->query($sql);
178         $rows = $this->bean->db->fetchByAssoc($result);
179
180         //assert that if we return name of Calendar module
181         //create relation between created Meeting and current User
182         if($return_module)
183         {
184             $this->assertNotNull($rows);
185         }
186         else
187         {
188             $this->assertFalse($rows);
189         }
190     }
191 }