All Data Structures Functions Variables Pages
LanguageSuperUserWalkthroughTest.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo 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 ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo 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 Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified 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 Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
44  {
45  public static function setUpBeforeClass()
46  {
47  parent::setUpBeforeClass();
48  SecurityTestHelper::createSuperAdmin();
49  $super = User::getByUsername('super');
50  Yii::app()->user->userModel = $super;
51  }
52 
53  public function testSuperUserAllDefaultControllerActions()
54  {
55  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
56 
57  // Test all default controller actions that do not require any POST/GET variables to be passed.
58  // This does not include portlet controller actions.
59  $this->runControllerWithNoExceptionsAndGetContent ('zurmo/language');
60  $this->runControllerWithNoExceptionsAndGetContent ('zurmo/language/configurationList');
61  }
62 
63  public function testSuperUserActivateLanguages()
64  {
65  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
66 
67  // Confirm only english is the active language.
68  $data = Yii::app()->languageHelper->getActiveLanguagesDataForTesting();
69  $this->assertArrayHasKey('en', $data);
70  $compareData = array(
71  'en' => array(
72  'canDeactivate' => false,
73  'label' => 'English (English)',
74  'nativeName' => 'English',
75  'name' => 'English'
76  ),
77  );
78  $this->assertEquals($compareData, $data);
79 
80  // Activate German
81  $this->resetGetArray();
82  $this->resetPostArray();
83  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/language/activate/languageCode/de');
84  $this->assertContains('activated successfully', $content);
85 
86  // Activate Italian
87  $this->resetGetArray();
88  $this->resetPostArray();
89  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/language/activate/languageCode/it');
90  $this->assertContains('activated successfully', $content);
91 
92  // Confirm the new languages are active
93  $data = Yii::app()->languageHelper->getActiveLanguagesDataForTesting();
94  $compareData = array(
95  'en' => array(
96  'canDeactivate' => false,
97  'label' => 'English (English)',
98  'nativeName' => 'English',
99  'name' => 'English'
100  ),
101  'de' => array(
102  'canDeactivate' => true,
103  'label' => 'German (Deutsch)',
104  'nativeName' => 'Deutsch',
105  'name' => 'German'
106  ),
107  'it' => array(
108  'canDeactivate' => true,
109  'label' => 'Italian (Italiano)',
110  'nativeName' => 'Italiano',
111  'name' => 'Italian'
112  ),
113  );
114  $this->assertEquals($compareData, $data);
115  }
116 
121  {
122  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
123 
124  // Confirm German is active
125  $data = Yii::app()->languageHelper->getActiveLanguagesDataForTesting();
126  $this->assertArrayHasKey('de', $data);
127  $compareData = array(
128  'canDeactivate' => true,
129  'label' => 'German (Deutsch)',
130  'nativeName' => 'Deutsch',
131  'name' => 'German'
132  );
133  $this->assertEquals($compareData, $data['de']);
134 
135  // Update German
136  $this->resetGetArray();
137  $this->resetPostArray();
138  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/language/update/languageCode/de');
139  $this->assertContains('updated successfully', $content);
140  }
141 
146  {
147  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
148 
149  // Confirm German and Italian are active
150  $data = Yii::app()->languageHelper->getActiveLanguagesDataForTesting();
151  $compareData = array(
152  'en' => array(
153  'canDeactivate' => false,
154  'label' => 'English (English)',
155  'nativeName' => 'English',
156  'name' => 'English'
157  ),
158  'de' => array(
159  'canDeactivate' => true,
160  'label' => 'German (Deutsch)',
161  'nativeName' => 'Deutsch',
162  'name' => 'German'
163  ),
164  'it' => array(
165  'canDeactivate' => true,
166  'label' => 'Italian (Italiano)',
167  'nativeName' => 'Italiano',
168  'name' => 'Italian'
169  ),
170  );
171  $this->assertEquals($compareData, $data);
172 
173  // Deactivate German
174  $this->resetGetArray();
175  $this->resetPostArray();
176  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/language/deactivate/languageCode/de');
177  $this->assertContains('deactivated successfully', $content);
178 
179  // Confirm the correct languages are active.
180  $data = Yii::app()->languageHelper->getActiveLanguagesDataForTesting();
181  $compareData = array(
182  'en' => array(
183  'canDeactivate' => false,
184  'label' => 'English (English)',
185  'nativeName' => 'English',
186  'name' => 'English'
187  ),
188  'it' => array(
189  'canDeactivate' => true,
190  'label' => 'Italian (Italiano)',
191  'nativeName' => 'Italiano',
192  'name' => 'Italian'
193  ),
194  );
195  $this->assertEquals($compareData, $data);
196  }
197  }
198 ?>
static getByUsername($username)
Definition: User.php:49
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
Generated on Fri May 29 2020 07:10:36