Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
InstallWalkthroughTest.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  ********************************************************************************/
42  {
43  protected $perInstanceConfigContents = "";
44  protected $debugConfigContents = "";
45  protected $perInstanceFile;
46  protected $debugFile;
47  protected $instanceRoot;
48 
49  protected $databaseHostname;
50  protected $databaseUsername;
51  protected $databasePassword;
52  protected $databasePort;
53  protected $databaseName;
54  protected $superUserPassword;
55 
56  public function setUp()
57  {
58  parent::setUp();
59  list(, $this->databaseHostname, $this->databasePort, $this->databaseName) = array_values(RedBeanDatabase::getDatabaseInfoFromDsnString(Yii::app()->db->connectionString));
60  $this->databaseUsername = Yii::app()->db->username;
61  $this->databasePassword = Yii::app()->db->password;
62  $this->superUserPassword = 'super';
63 
64  $this->instanceRoot = INSTANCE_ROOT;
65  $this->perInstanceFile = "{$this->instanceRoot}/protected/config/perInstanceTest.php";
66  $this->debugFile = "{$this->instanceRoot}/protected/config/debugTest.php";
67 
68  if (is_file($this->perInstanceFile))
69  {
70  $this->perInstanceConfigContents = file_get_contents($this->perInstanceFile);
71  unlink($this->perInstanceFile);
72  }
73  if (is_file($this->debugFile))
74  {
75  $this->debugConfigContents = file_get_contents($this->debugFile);
76  unlink($this->debugFile);
77  }
78  Yii::app()->gameHelper->muteScoringModelsOnSave();
79  }
80 
81  public function teardown()
82  {
83  if (strlen($this->perInstanceConfigContents))
84  {
85  file_put_contents($this->perInstanceFile, $this->perInstanceConfigContents);
86  }
87  else
88  {
89  unlink($this->perInstanceFile);
90  }
91 
92  if (strlen($this->debugConfigContents))
93  {
94  file_put_contents($this->debugFile, $this->debugConfigContents);
95  }
96  else
97  {
98  unlink($this->debugFile);
99  }
100  Yii::app()->gameHelper->unmuteScoringModelsOnSave();
101  parent::teardown();
102  }
103 
104  public function testAllActions()
105  {
106  //Ensure that installed = false
107  Yii::app()->setApplicationInstalled(false);
108 
109  //Check index action.
110  $this->runControllerWithNoExceptionsAndGetContent('install/default');
111  $this->runControllerWithNoExceptionsAndGetContent('install/default/index');
112 
113  //Check welcome action.
114  $this->runControllerWithNoExceptionsAndGetContent('install/default/welcome');
115 
116  //Check checkSystem action.
117  if (isset($_SERVER['SERVER_SOFTWARE']))
118  {
119  $serverSoftware = $_SERVER['SERVER_SOFTWARE'];
120  }
121  $_SERVER['SERVER_SOFTWARE'] = 'Apache';
122  $this->runControllerWithNoExceptionsAndGetContent('install/default/checkSystem');
123 
124  //Check settings action.
125  $this->runControllerWithNoExceptionsAndGetContent('install/default/settings');
126 
127  //Check validateSettings action.
128  //First validation will fail, and there should be at least validation errors.
129  $this->setPostArray(array(
130  'ajax' => 'install-form',
131  'InstallSettingsForm' => array(
132  'databaseHostname' => '',
133  'databaseAdminUsername' => '',
134  'databaseAdminPassword' => '',
135  'databaseName' => '',
136  'databaseUsername' => '',
137  'databasePassword' => '',
138  'databasePort' => '',
139  'superUserPassword' => '',
140  'memcacheHostname' => '',
141  'memcachePortNumber' => '',
142  'memcacheAvailable' => '',
143  'databaseType' => 'mysql',
144  'removeExistingData' => '',
145  'installDemoData' => '',
146  )));
147  $content = $this->runControllerWithExitExceptionAndGetContent('install/default/settings');
148  $errors = CJSON::decode($content);
149  $this->assertGreaterThanOrEqual(5, count($errors));
150 
151  $postData = array(
152  'ajax' => 'install-form',
153  'InstallSettingsForm' => array(
154  'databaseHostname' => $this->databaseHostname,
155  'databaseAdminUsername' => '',
156  'databaseAdminPassword' => '',
157  'databaseName' => $this->databaseName,
158  'databaseUsername' => $this->databaseUsername,
159  'databasePassword' => $this->databasePassword,
160  'databasePort' => $this->databasePort,
161  'superUserPassword' => $this->superUserPassword,
162  'databaseType' => 'mysql',
163  'removeExistingData' => '1',
164  'installDemoData' => '',
165  )
166  );
167  if (MEMCACHE_ON)
168  {
169  $memcacheSettings = array(
170  'memcacheHostname' => 'localhost',
171  'memcachePortNumber' => '11211',
172  'memcacheAvailable' => '1',
173  );
174  }
175  else
176  {
177  $memcacheSettings = array(
178  'memcacheHostname' => '',
179  'memcachePortNumber' => '',
180  'memcacheAvailable' => '0',
181  );
182  }
183  $postData['InstallSettingsForm'] = array_merge(
184  $postData['InstallSettingsForm'], $memcacheSettings
185  );
186 
187  $this->setPostArray($postData);
188 
189  $content = $this->runControllerWithExitExceptionAndGetContent('install/default/settings');
190  $errors = CJSON::decode($content);
191  $this->assertEquals(1, count($errors));
192 
193  $postData['InstallSettingsForm']['hostInfo'] = 'http://www.example.com';
194  $this->setPostArray($postData);
195 
196  $content = $this->runControllerWithExitExceptionAndGetContent('install/default/settings');
197  $errors = CJSON::decode($content);
198  $this->assertEquals(0, count($errors));
199 
200  //Run installation.
201  $this->setPostArray(array(
202  'InstallSettingsForm' => array(
203  'databaseHostname' => $this->databaseHostname,
204  'databaseAdminUsername' => '',
205  'databaseAdminPassword' => '',
206  'databaseName' => $this->databaseName,
207  'databaseUsername' => $this->databaseUsername,
208  'databasePassword' => $this->databasePassword,
209  'databasePort' => $this->databasePort,
210  'superUserPassword' => $this->superUserPassword,
211  'memcacheHostname' => 'localhost',
212  'memcachePortNumber' => '11211',
213  'memcacheAvailable' => '1',
214  'databaseType' => 'mysql',
215  'removeExistingData' => '1',
216  'installDemoData' => '',
217  'hostInfo' => 'http://www.example.com'
218  )));
219 
220  //Close db connection(new will be created during installation process).
221  RedBeanDatabase::close();
222  $this->runControllerWithExitExceptionAndGetContent('install/default/settings');
223  $industryFieldData = CustomFieldData::getByName('Industries');
224  $this->assertGreaterThan('0', count(unserialize($industryFieldData->serializedData)));
225 
226  //Check installDemoData action.
227  RedBeanDatabase::close();
228  DemoDataUtil::unsetLoadedModules();
229  $this->runControllerWithNoExceptionsAndGetContent('install/default/installDemoData');
230  $this->assertGreaterThan('0', Account::getAll());
231  $this->assertGreaterThan('0', Contact::getAll());
232 
233  //Restore $_SERVER['SERVER_SOFTWARE']
234  if (isset($serverSoftware))
235  {
236  $_SERVER['SERVER_SOFTWARE'] = $serverSoftware;
237  }
238  else
239  {
240  unset($_SERVER['SERVER_SOFTWARE']);
241  }
242  }
243  }
244 ?>
static getDatabaseInfoFromDsnString($dsn)
static getByName($name, $shouldCache=true)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null)
Generated on Tue Jul 14 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.