Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 537 lines (435 sloc) 23.339 kb
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
1 <?php
f57e452 @amygdala Issue #266: Include license information at the top of each source file
amygdala authored
2 /**
3 *
4 * ThinkUp/tests/TestOfAccountConfigurationController.php
5 *
defa933 @ginatrapani Issue #266: License/copyright corrections and additions
ginatrapani authored
6 * Copyright (c) 2009-2010 Gina Trapani
f57e452 @amygdala Issue #266: Include license information at the top of each source file
amygdala authored
7 *
8 * LICENSE:
9 *
10 * This file is part of ThinkUp (http://thinkupapp.com).
11 *
defa933 @ginatrapani Issue #266: License/copyright corrections and additions
ginatrapani authored
12 * ThinkUp is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any
f57e452 @amygdala Issue #266: Include license information at the top of each source file
amygdala authored
14 * later version.
15 *
defa933 @ginatrapani Issue #266: License/copyright corrections and additions
ginatrapani authored
16 * ThinkUp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
f57e452 @amygdala Issue #266: Include license information at the top of each source file
amygdala authored
18 * details.
19 *
defa933 @ginatrapani Issue #266: License/copyright corrections and additions
ginatrapani authored
20 * You should have received a copy of the GNU General Public License along with ThinkUp. If not, see
f57e452 @amygdala Issue #266: Include license information at the top of each source file
amygdala authored
21 * <http://www.gnu.org/licenses/>.
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
22 *
23 *
24 * Test of AccountConfigurationController
25 *
26 * @license http://www.gnu.org/licenses/gpl.html
27 * @copyright 2009-2010 Gina Trapani
28 * @author Gina Trapani <ginatrapani[at]gmail[dot]com>
29 *
defa933 @ginatrapani Issue #266: License/copyright corrections and additions
ginatrapani authored
30 */
18e55f6 @diazuwi Issue #115: Implemented project-wide class lazy loading
diazuwi authored
31 require_once dirname(__FILE__).'/init.tests.php';
82bf1d8 @ginatrapani Issue #183: Major file reorganization in preparation for user distrib…
ginatrapani authored
32 require_once THINKUP_ROOT_PATH.'webapp/_lib/extlib/simpletest/autorun.php';
18e55f6 @diazuwi Issue #115: Implemented project-wide class lazy loading
diazuwi authored
33 require_once THINKUP_ROOT_PATH.'webapp/config.inc.php';
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
34
18e55f6 @diazuwi Issue #115: Implemented project-wide class lazy loading
diazuwi authored
35 if (isset($RUNNING_ALL_TESTS) && !$RUNNING_ALL_TESTS) {
82bf1d8 @ginatrapani Issue #183: Major file reorganization in preparation for user distrib…
ginatrapani authored
36 require_once THINKUP_ROOT_PATH.'webapp/_lib/extlib/twitteroauth/twitteroauth.php';
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
37 }
18e55f6 @diazuwi Issue #115: Implemented project-wide class lazy loading
diazuwi authored
38 require_once THINKUP_ROOT_PATH.'webapp/plugins/twitter/model/class.TwitterOAuthThinkUp.php';
39 require_once THINKUP_ROOT_PATH.'webapp/plugins/twitter/model/class.TwitterPlugin.php';
40 require_once THINKUP_ROOT_PATH.'webapp/plugins/twitter/controller/class.TwitterPluginConfigurationController.php';
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
41
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
42
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
43 class TestOfAccountConfigurationController extends ThinkUpUnitTestCase {
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
44
45 public function __construct() {
46 $this->UnitTestCase('AccountConfigurationController class test');
47 }
48
49 public function setUp(){
50 parent::setUp();
51 $webapp = Webapp::getInstance();
52 $webapp->registerPlugin('twitter', 'TwitterPlugin');
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
53 $this->builders = self::buildData();
54 }
55
56 public function tearDown() {
57 $this->builders = null;
58 parent::tearDown();
59 }
60
61 protected function buildData() {
62 $builders = array();
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
63
64 //Add owner
65 $session = new Session();
66 $cryptpass = $session->pwdcrypt("oldpassword");
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
67 $builders[] = FixtureBuilder::build('owners', array('id'=>1, 'full_name'=>'ThinkUp J. User',
68 'email'=>'me@example.com', 'is_activated'=>1, 'pwd'=>$cryptpass));
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
69
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
70 $builders[] = FixtureBuilder::build('owners', array('id'=>2, 'full_name'=>'ThinkUp J. Admin',
71 'email'=>'admin@example.com', 'is_activated'=>1, 'is_admin'=>1));
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
72
73 //Add instance_owner
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
74 $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>1));
75 $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>2, 'instance_id'=>1));
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
76
77 //Insert test data into test table
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
78 $builders[] = FixtureBuilder::build('users', array('user_id'=>13, 'user_name'=>'ev',
79 'full_name'=>'Ev Williams'));
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
80
81 //Make public
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
82 //Insert test data into test table
83 $builders[] = FixtureBuilder::build('instances', array('id'=>1, 'network_user_id'=>13,
84 'network_username'=>'ev', 'is_public'=>1, 'network'=>'twitter'));
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
85
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
86 return $builders;
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
87 }
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
88
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
89 public function testConstructor() {
90 $controller = new AccountConfigurationController(true);
91 $this->assertTrue(isset($controller), 'constructor test');
92
93 $v_mgr = $controller->getViewManager();
94 $this->assertEqual($v_mgr->getTemplateDataItem('controller_title'), 'Configure Your Account');
95 }
96
f063925 @ginatrapani Issue #27: Delete instances (network accounts) in Configuration area
ginatrapani authored
97 public function testDeleteExistingInstanceAsAdmin() {
98 $instance_dao = new InstanceMySQLDAO();
99 $owner_instance_dao = new OwnerInstanceMySQLDAO();
100
101 //Admin: should delete all owner instances and instance
102 $this->simulateLogin('admin@example.com', true);
103 $_POST['action'] = "delete";
104 $_POST["instance_id"] = 1;
105 $controller = new AccountConfigurationController(true);
106
107 //before
108 $instance = $instance_dao->get(1);
109 $this->assertNotNull($instance);
110
111 $owner_instances = $owner_instance_dao->getByInstance(1);
112 $this->assertNotNull($owner_instances);
113 $this->assertIsA($owner_instances, 'Array');
114 $this->assertEqual(sizeof($owner_instances), 2);
115
116 //process controller
117 $controller->go();
118
119 //instance should be deleted
120 $instance = $instance_dao->get(1);
121 $this->assertNull($instance);
122
123 //all owner_instances should be deleted
124 $owner_instances = $owner_instance_dao->getByInstance(1);
125 $this->assertIsA($owner_instances, 'Array');
126 $this->assertEqual(sizeof($owner_instances), 0);
127
128 $v_mgr = $controller->getViewManager();
129 $this->assertNotNull($v_mgr->getTemplateDataItem('successmsg'));
130 $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), 'Account deleted.');
131 $this->assertNull($v_mgr->getTemplateDataItem('errormsg'));
132 }
133
134 public function testDeleteExistingInstanceWithPrivilegesNoOtherOwners() {
135 $builders = array();
136 $builders[] = FixtureBuilder::build('instances', array('id'=>2, 'network_user_id'=>12,
137 'network_username'=>'tuinstance', 'network'=>'twitter'));
138
139 $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>2,
140 'oauth_access_token'=>'xxx', 'oauth_access_token_secret'=>'yyy'));
141
142 //Not admin with access privs, no other owners (delete owner instance AND instance)
143 $instance_dao = new InstanceMySQLDAO();
144 $owner_instance_dao = new OwnerInstanceMySQLDAO();
145
146 //Should delete the owner instance, and since there's no other owner, the instance itself
147 $this->simulateLogin('me@example.com');
148 $_POST['action'] = "delete";
149 $_POST["instance_id"] = 2;
150 $controller = new AccountConfigurationController(true);
151
152 //before
153 $instance = $instance_dao->get(2);
154 $this->assertNotNull($instance);
155
156 $owner_instances = $owner_instance_dao->getByInstance(2);
157 $this->assertNotNull($owner_instances);
158 $this->assertIsA($owner_instances, 'Array');
159 $this->assertEqual(sizeof($owner_instances), 1);
160
161 //process controller
162 $controller->go();
163
164 //instance should be deleted
165 $instance = $instance_dao->get(2);
166 $this->assertNull($instance);
167
168 //all owner_instances should be deleted
169 $owner_instances = $owner_instance_dao->getByInstance(2);
170 $this->assertIsA($owner_instances, 'Array');
171 $this->assertEqual(sizeof($owner_instances), 0);
172
173 $v_mgr = $controller->getViewManager();
174 $this->assertNotNull($v_mgr->getTemplateDataItem('successmsg'));
175 $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), 'Account deleted.');
176 $this->assertNull($v_mgr->getTemplateDataItem('errormsg'));
177 }
178
179 public function testDeleteExistingInstanceWithPrivilegesWithOtherOwners() {
180 //Not admin with access privs, with other owners (delete owner instance and NOT instance)
181 $builders = array();
182 $builders[] = FixtureBuilder::build('instances', array('id'=>2, 'network_user_id'=>12,
183 'network_username'=>'tuinstance', 'network'=>'twitter'));
184
185 $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>1, 'instance_id'=>2,
186 'oauth_access_token'=>'xxx', 'oauth_access_token_secret'=>'yyy'));
187
188 $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>2, 'instance_id'=>2,
189 'oauth_access_token'=>'xxx', 'oauth_access_token_secret'=>'yyy'));
190
191 $instance_dao = new InstanceMySQLDAO();
192 $owner_instance_dao = new OwnerInstanceMySQLDAO();
193
194 //Should delete the owner instance but leave the instance alone
195 $this->simulateLogin('me@example.com');
196 $_POST['action'] = "delete";
197 $_POST["instance_id"] = 2;
198 $controller = new AccountConfigurationController(true);
199
200 //before
201 $instance = $instance_dao->get(2);
202 $this->assertNotNull($instance);
203
204 $owner_instances = $owner_instance_dao->getByInstance(2);
205 $this->assertNotNull($owner_instances);
206 $this->assertIsA($owner_instances, 'Array');
207 $this->assertEqual(sizeof($owner_instances), 2);
208
209 //process controller
210 $controller->go();
211
212 //instance should NOT be deleted
213 $instance = $instance_dao->get(2);
214 $this->assertNotNull($instance);
215
216 //just one owner_instance should be deleted
217 $owner_instances = $owner_instance_dao->getByInstance(2);
218 $this->assertIsA($owner_instances, 'Array');
219 $this->assertEqual(sizeof($owner_instances), 1);
220
221 $v_mgr = $controller->getViewManager();
222 $this->assertNotNull($v_mgr->getTemplateDataItem('successmsg'));
223 $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), 'Account deleted.');
224 $this->assertNull($v_mgr->getTemplateDataItem('errormsg'));
225 }
226
227 public function testDeleteExistingInstanceNoPrivileges() {
228 //Not admin without access privs (set error messages)
229 $builders = array();
230 $builders[] = FixtureBuilder::build('instances', array('id'=>2, 'network_user_id'=>12,
231 'network_username'=>'tuinstance', 'network'=>'twitter'));
232
233 $builders[] = FixtureBuilder::build('owner_instances', array('owner_id'=>2, 'instance_id'=>2,
234 'oauth_access_token'=>'xxx', 'oauth_access_token_secret'=>'yyy'));
235
236 $instance_dao = new InstanceMySQLDAO();
237 $owner_instance_dao = new OwnerInstanceMySQLDAO();
238
239 //Should delete the owner instance but leave the instance alone
240 $this->simulateLogin('me@example.com');
241 $_POST['action'] = "delete";
242 $_POST["instance_id"] = 2;
243 $controller = new AccountConfigurationController(true);
244
245 //before
246 $instance = $instance_dao->get(2);
247 $this->assertNotNull($instance);
248
249 $owner_instances = $owner_instance_dao->getByInstance(2);
250 $this->assertNotNull($owner_instances);
251 $this->assertIsA($owner_instances, 'Array');
252 $this->assertEqual(sizeof($owner_instances), 1);
253
254 //process controller
255 $controller->go();
256
257 //instance should NOT be deleted
258 $instance = $instance_dao->get(2);
259 $this->assertNotNull($instance);
260
261 //owner instance should NOT be deleted
262 $owner_instances = $owner_instance_dao->getByInstance(2);
263 $this->assertIsA($owner_instances, 'Array');
264 $this->assertEqual(sizeof($owner_instances), 1);
265
266 $v_mgr = $controller->getViewManager();
267 $this->assertNull($v_mgr->getTemplateDataItem('successmsg'));
268 $this->assertNotNull($v_mgr->getTemplateDataItem('errormsg'));
269 $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'), 'Insufficient privileges.');
270 }
271
272 public function testDeleteNonExistentInstance() {
273 //Not admin, non existent instance (set error message)
274
275 $instance_dao = new InstanceMySQLDAO();
276 $owner_instance_dao = new OwnerInstanceMySQLDAO();
277
278 //Should delete the owner instance but leave the instance alone
279 $this->simulateLogin('me@example.com');
280 $_POST['action'] = "delete";
281 $_POST["instance_id"] = 57;
282 $controller = new AccountConfigurationController(true);
283
284 //process controller
285 $controller->go();
286
287 //set error msg
288 $v_mgr = $controller->getViewManager();
289 $this->assertNull($v_mgr->getTemplateDataItem('successmsg'));
290 $this->assertNotNull($v_mgr->getTemplateDataItem('errormsg'));
291 $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'), 'Instance doesn\'t exist.');
292 }
293
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
294 public function testControlNotLoggedIn() {
295 $controller = new AccountConfigurationController(true);
296 $results = $controller->go();
297
c3f5b33 @ginatrapani Issue #111: Parent controller now outputs all exceptions on a custom …
ginatrapani authored
298 $v_mgr = $controller->getViewManager();
299 $config = Config::getInstance();
300 $this->assertEqual('You must <a href="'.$config->getValue('site_root_path').
301 'session/login.php">log in</a> to do this.', $v_mgr->getTemplateDataItem('errormsg'));
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
302 }
303
304 public function testAuthControlLoggedInNotAdmin() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
305 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
306 $controller = new AccountConfigurationController(true);
307 $results = $controller->go();
308
309 //test if view variables were set correctly
310 $v_mgr = $controller->getViewManager();
311 $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
715ab81 @ekanshpreet Issue #122: GeoEncoder plugin
ekanshpreet authored
312 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
313
314 $owner = $v_mgr->getTemplateDataItem('owner');
315 $this->assertIsA($owner, 'Owner');
316 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
317 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
318 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
319
320 //not set: owners, body, successmsg, errormsg
321 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
322 $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
323 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
324 $this->assertTrue(!$v_mgr->getTemplateDataItem('errormsg'));
325 }
326
327 public function testAuthControlLoggedInAdmin() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
328 $this->simulateLogin('admin@example.com', true);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
329 $controller = new AccountConfigurationController(true);
330 $results = $controller->go();
331
332 //test if view variables were set correctly
333 $v_mgr = $controller->getViewManager();
334 $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
715ab81 @ekanshpreet Issue #122: GeoEncoder plugin
ekanshpreet authored
335 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
336
337 $owner = $v_mgr->getTemplateDataItem('owner');
338 $this->assertIsA($owner, 'Owner');
339 $this->assertTrue($owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
340 $this->assertEqual($owner->full_name, 'ThinkUp J. Admin');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
341 $this->assertEqual($owner->email, 'admin@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
342 $this->assertIsA($v_mgr->getTemplateDataItem('owners'), 'array');
343 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('owners')), 2);
344
345 //not set: owners, body, successmsg, errormsg
346 $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
347 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
348 $this->assertTrue(!$v_mgr->getTemplateDataItem('errormsg'));
349 }
350
351 public function testAuthControlLoggedInSpecificPluginExists() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
352 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
353 $_GET['p'] = 'twitter';
354 $controller = new AccountConfigurationController(true);
355 $results = $controller->go();
356
357 //test if view variables were set correctly
358 $v_mgr = $controller->getViewManager();
359
360 $owner = $v_mgr->getTemplateDataItem('owner');
361 $this->assertIsA($owner, 'Owner');
362 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
363 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
364 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
365 $this->assertTrue($v_mgr->getTemplateDataItem('body'));
366
367 //not set: owners, body, successmsg, errormsg
368 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
369 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
370 $this->assertTrue(!$v_mgr->getTemplateDataItem('errormsg'));
371 $this->assertTrue(!$v_mgr->getTemplateDataItem('installed_plugins'));
372 }
373
374 public function testAuthControlLoggedInSpecificPluginDoesNotExist() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
375 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
376 $_GET['p'] = 'idontexist';
377 $controller = new AccountConfigurationController(true);
378 $results = $controller->go();
379
380 $v_mgr = $controller->getViewManager();
c3f5b33 @ginatrapani Issue #111: Parent controller now outputs all exceptions on a custom …
ginatrapani authored
381 $config = Config::getInstance();
382 $this->assertEqual('No plugin object defined for: idontexist', $v_mgr->getTemplateDataItem('errormsg'));
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
383 $owner = $v_mgr->getTemplateDataItem('owner');
384 $this->assertIsA($owner, 'Owner');
385 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
386 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
387 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
388
389 //not set: owners, body, successmsg, errormsg
390 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
391 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
392 $this->assertTrue(!$v_mgr->getTemplateDataItem('installed_plugins'));
393 }
394
395 public function testAuthControlLoggedInChangePasswordSuccess() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
396 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
397 $_POST['changepass'] = 'Change password';
398 $_POST['oldpass'] = 'oldpassword';
399 $_POST['pass1'] = 'newpassword';
400 $_POST['pass2'] = 'newpassword';
401
402 $controller = new AccountConfigurationController(true);
403 $results = $controller->go();
404
405 //test if view variables were set correctly
406 $v_mgr = $controller->getViewManager();
407 $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
715ab81 @ekanshpreet Issue #122: GeoEncoder plugin
ekanshpreet authored
408 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
409
410 $owner = $v_mgr->getTemplateDataItem('owner');
411 $this->assertIsA($owner, 'Owner');
412 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
413 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
414 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
415 $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), 'Your password has been updated.');
416
417 //not set: owners, body, successmsg, errormsg
418 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
419 $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
420 $this->assertTrue(!$v_mgr->getTemplateDataItem('errormsg'));
421 }
422
423 public function testAuthControlLoggedInChangePasswordOldPwdDoesntMatch() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
424 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
425 $_POST['changepass'] = 'Change password';
426 $_POST['oldpass'] = 'oldddpassword';
427 $_POST['pass1'] = 'newpassword';
428 $_POST['pass2'] = 'newpassword';
429
430 $controller = new AccountConfigurationController(true);
431 $results = $controller->go();
432
433 //test if view variables were set correctly
434 $v_mgr = $controller->getViewManager();
435 $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
715ab81 @ekanshpreet Issue #122: GeoEncoder plugin
ekanshpreet authored
436 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
437
438 $owner = $v_mgr->getTemplateDataItem('owner');
439 $this->assertIsA($owner, 'Owner');
440 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
441 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
442 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
443 $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'), 'Old password does not match or empty.');
444
445 //not set: owners, body, successmsg, errormsg
446 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
447 $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
448 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
449 }
450
451 public function testAuthControlLoggedInChangePasswordOldPwdEmpty() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
452 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
453 $_POST['changepass'] = 'Change password';
454 $_POST['oldpass'] = '';
455 $_POST['pass1'] = 'newpassword';
456 $_POST['pass2'] = 'newpassword';
457
458 $controller = new AccountConfigurationController(true);
459 $results = $controller->go();
460
461 //test if view variables were set correctly
462 $v_mgr = $controller->getViewManager();
463 $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
715ab81 @ekanshpreet Issue #122: GeoEncoder plugin
ekanshpreet authored
464 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
465
466 $owner = $v_mgr->getTemplateDataItem('owner');
467 $this->assertIsA($owner, 'Owner');
468 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
469 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
470 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
471 $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'), 'Old password does not match or empty.');
472
473 //not set: owners, body, successmsg, errormsg
474 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
475 $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
476 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
477 }
478
479 public function testAuthControlLoggedInChangePasswordNewPwdsDontMatch() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
480 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
481 $_POST['changepass'] = 'Change password';
482 $_POST['oldpass'] = 'oldpassword';
483 $_POST['pass1'] = 'newpassword1';
484 $_POST['pass2'] = 'newpassword2';
485
486 $controller = new AccountConfigurationController(true);
487 $results = $controller->go();
488
489 //test if view variables were set correctly
490 $v_mgr = $controller->getViewManager();
491 $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
715ab81 @ekanshpreet Issue #122: GeoEncoder plugin
ekanshpreet authored
492 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
493
494 $owner = $v_mgr->getTemplateDataItem('owner');
495 $this->assertIsA($owner, 'Owner');
496 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
497 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
498 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
499 $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'),
500 'New passwords did not match. Your password has not been changed.');
501
502 //not set: owners, body, successmsg, errormsg
503 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
504 $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
505 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
506 }
507
508 public function testAuthControlLoggedInChangePasswordNewPwdTooShort() {
ff7c4fb @ginatrapani Issue #160: ThinkUp user session is now installation-specific, not se…
ginatrapani authored
509 $this->simulateLogin('me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
510 $_POST['changepass'] = 'Change password';
511 $_POST['oldpass'] = 'oldpassword';
512 $_POST['pass1'] = 'new1';
513 $_POST['pass2'] = 'new1';
514
515 $controller = new AccountConfigurationController(true);
516 $results = $controller->go();
517
518 //test if view variables were set correctly
519 $v_mgr = $controller->getViewManager();
520 $this->assertIsA($v_mgr->getTemplateDataItem('installed_plugins'), 'array');
715ab81 @ekanshpreet Issue #122: GeoEncoder plugin
ekanshpreet authored
521 $this->assertEqual(sizeof($v_mgr->getTemplateDataItem('installed_plugins')), 6);
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
522
523 $owner = $v_mgr->getTemplateDataItem('owner');
524 $this->assertIsA($owner, 'Owner');
525 $this->assertTrue(!$owner->is_admin);
aa94f50 @ginatrapani [DB MIGRATION RECOMMENDED] Issue #157: Refactored all code for ThinkT…
ginatrapani authored
526 $this->assertEqual($owner->full_name, 'ThinkUp J. User');
ae3c9aa @ginatrapani [DB MIGRATION REQ'D] Issue #136: Clean up owners table
ginatrapani authored
527 $this->assertEqual($owner->email, 'me@example.com');
fb9ce53 @ginatrapani Issue #111: Ported Account Configuration controller
ginatrapani authored
528 $this->assertEqual($v_mgr->getTemplateDataItem('errormsg'),
529 'New password must be at least 5 characters. Your password has not been changed.');
530
531 //not set: owners, body, successmsg, errormsg
532 $this->assertTrue(!$v_mgr->getTemplateDataItem('owners'));
533 $this->assertTrue(!$v_mgr->getTemplateDataItem('body'));
534 $this->assertTrue(!$v_mgr->getTemplateDataItem('successmsg'));
535 }
536 }
Something went wrong with that request. Please try again.