public function testSuccessfulInstallationAndAccountActivation() { self::setUpDefaultFolderInstallation(); require THINKUP_WEBAPP_PATH . 'config.inc.php'; //Config file doesn't exist $this->assertFalse(file_exists($THINKUP_CFG['source_root_path'] . '/webapp/test_installer/thinkup/config.inc.php')); //sleep(1000); //Start installation process $this->get($this->url . '/test_installer/thinkup/'); $this->assertTitle("ThinkUp"); $this->assertText('ThinkUp\'s configuration file does not exist! Try installing ThinkUp.'); $this->clickLink("installing ThinkUp."); $this->assertText('Great! Your system has everything it needs to run ThinkUp.'); $this->clickLinkById('nextstep'); //sleep(1000); $this->assertText('Create Your ThinkUp Account'); $this->setField('full_name', 'ThinkUp J. User'); $this->setField('site_email', '*****@*****.**'); $this->setField('password', 'secret12345'); $this->setField('confirm_password', 'secret12345'); $this->setField('timezone', 'America/Los_Angeles'); $this->setField('db_host', $THINKUP_CFG['db_host']); $this->setField('db_name', $this->test_database_name); $this->setField('db_user', $THINKUP_CFG['db_user']); $this->setField('db_passwd', $THINKUP_CFG['db_password']); $this->setField('db_socket', $THINKUP_CFG['db_socket']); $this->setField('db_prefix', $THINKUP_CFG['table_prefix']); $this->clickSubmitByName('Submit'); $this->assertText('ThinkUp has been installed successfully. Check your email account; an account activation ' . 'message has been sent.'); //Config file has been written $this->assertTrue(file_exists($THINKUP_CFG['source_root_path'] . '/webapp/test_installer/thinkup/config.inc.php')); //sleep(1000); //Test bad activation code $this->get($this->url . '/test_installer/thinkup/session/activate.php?usr=user@example.com&code=dummycode'); $this->assertText('Houston, we have a problem: Account activation failed.'); //Get activation code for user from database Utils::setDefaultTimezonePHPini(); $owner_dao = new OwnerMySQLDAO(); $code = $owner_dao->getActivationCode('*****@*****.**'); $activation_code = $code['activation_code']; //Visit activation page $this->get($this->url . '/test_installer/thinkup/session/activate.php?usr=user@example.com&code=' . $activation_code); $this->assertNoText('Houston, we have a problem: Account activation failed.'); $this->assertText('Success! Your account has been activated. Please log in.'); //Log into ThinkUp $this->clickLink('Log in'); $this->setField('email', '*****@*****.**'); $this->setField('pwd', 'secret12345'); $this->click("Log In"); $this->assertText('Welcome to ThinkUp. Let\'s get started.'); //$this->showSource(); //Visit Settings page and assert content there $this->click("Settings"); $this->assertTitle('Configure Your Account | ThinkUp'); $this->assertText('admin'); }
public function testIsOwnerAuthorizedViaPrivateAPIKey() { $builders_array = array(); // build our data $builders_array[] = FixtureBuilder::build('owners', array('full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 0, 'is_admin' => 0, 'api_key_private' => '')); $builders_array[] = FixtureBuilder::build('owners', array('full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 1, 'is_admin' => 1, 'api_key_private' => 'aabbccdd')); // init our dao $dao = new OwnerMySQLDAO(); //empty api key for empty api key $result = $dao->isOwnerAuthorizedViaPrivateAPIKey('*****@*****.**', ''); $this->assertFalse($result); //wrong api key for email address $result = $dao->isOwnerAuthorizedViaPrivateAPIKey('*****@*****.**', 'xyz'); $this->assertFalse($result); //right api key for email address $result = $dao->isOwnerAuthorizedViaPrivateAPIKey('*****@*****.**', 'aabbccdd'); $this->assertTrue($result); //email address that doesn't exist $result = $dao->isOwnerAuthorizedViaPrivateAPIKey('*****@*****.**', 'aabbccdd'); $this->assertFalse($result); }
public function testForDeleteCSRFToken() { self::buildInstanceData(); $owner_instance_dao = new OwnerInstanceMySQLDAO(); $instance_dao = new InstanceMySQLDAO(); $owner_dao = new OwnerMySQLDAO(); $options_arry = $this->buildPluginOptions(); $this->simulateLogin('*****@*****.**', true, true); $owner = $owner_dao->getByEmail(Session::getLoggedInUser()); $controller = new FacebookPluginConfigurationController($owner, 'facebook'); // add mock page data to view $owner_instance_pages = array('123456' => array('id' => '123456', 'network_username' => 'test_username', 'network' => 'facebook')); $view = $controller->getViewManager(); $view->assign('owner_instance_pages', $owner_instance_pages); $output = $controller->go(); // looks for account delete token $this->assertPattern('/name="csrf_token" value="' . self::CSRF_TOKEN . '" \\/><!\\-\\- delete account csrf token \\-\\->/', $output); // looks for page delete token $this->assertPattern('/name="csrf_token" value="' . self::CSRF_TOKEN . '" \\/><!\\-\\- delete page csrf token \\-\\->/', $output); }
public function testReconnectAccount() { $owner_instance_dao = new OwnerInstanceMySQLDAO(); $instance_dao = new InstanceMySQLDAO(); $owner_dao = new OwnerMySQLDAO(); $_GET['p'] = 'facebook'; $_GET['perms'] = 'offline_access,read_stream,user_likes,user_location,user_website,read_friendlists'; $_GET['selected_profiles'] = '606837591'; $_GET['session'] = '{"session_key":"new-faux-access-token","uid":"606837591","expires":0,"secret":'. '"itsasecret","access_token":"new-faux-access-token","sig":"siggysigsig"}'; $options_arry = $this->buildPluginOptions(); $this->simulateLogin('*****@*****.**', true); $owner = $owner_dao->getByEmail(Session::getLoggedInUser()); $controller = new FacebookPluginConfigurationController($owner, 'facebook'); $output = $controller->go(); $v_mgr = $controller->getViewManager(); $this->assertEqual($v_mgr->getTemplateDataItem('successmsg'), "Success! You've reconnected your Facebook ". "account."); $instance = $instance_dao->getByUserIdOnNetwork('606837591', 'facebook'); $this->assertTrue(isset($instance)); $oinstance = $owner_instance_dao->get($owner->id, $instance->id); $this->assertTrue(isset($oinstance)); $this->assertEqual($oinstance->oauth_access_token, 'new-faux-access-token'); }
/** * Sets up initial app */ private function setUpApp($version, $MIGRATIONS) { // run updates and migrations require 'tests/migration-assertions.php'; $this->debug("Setting up base install for upgrade: $version"); $zip_url = $MIGRATIONS[$version]['zip_url']; require THINKUP_WEBAPP_PATH.'config.inc.php'; //install beta 1 $zipfile = $this->getInstall($zip_url, $version, $this->installs_dir); //Extract into test_installer directory and set necessary folder permissions exec('cp ' . $zipfile . ' webapp/test_installer/.;'. 'cd webapp/test_installer/;'. 'unzip ' . $zipfile . ';chmod -R 777 thinkup'); //Config file doesn't exist $this->assertFalse(file_exists($THINKUP_CFG['source_root_path']. 'webapp/test_installer/thinkup/config.inc.php')); //Set test mode $this->get($this->url.'/test_installer/thinkup/install/setmode.php?m=tests'); //Include config again to get test db credentials require THINKUP_WEBAPP_PATH.'config.inc.php'; //$this->showText(); //Start installation process $this->get($this->url.'/test_installer/thinkup/'); $this->assertTitle("ThinkUp"); $this->assertText('ThinkUp\'s configuration file does not exist! Try installing ThinkUp.'); $this->clickLink("installing ThinkUp."); $this->assertText('Great! Your system has everything it needs to run ThinkUp. You may proceed to the next '. 'step.'); //Set test mode putenv("MODE=TESTS"); //Include config again to get test db credentials require THINKUP_WEBAPP_PATH.'config.inc.php'; $this->get('index.php?step=2'); $this->assertText('Create Your ThinkUp Account'); $this->setField('full_name', 'ThinkUp J. User'); $this->setField('site_email', '*****@*****.**'); $this->setField('password', 'secret'); $this->setField('confirm_password', 'secret'); $this->setField('timezone', 'America/Los_Angeles'); $this->setField('db_host', $THINKUP_CFG['db_host']); $this->setField('db_name', $THINKUP_CFG['db_name']); $this->setField('db_user', $THINKUP_CFG['db_user']); $this->setField('db_passwd', $THINKUP_CFG['db_password']); $this->setField('db_socket', $THINKUP_CFG['db_socket']); $this->clickSubmitByName('Submit'); $this->assertText('ThinkUp has been installed successfully. Check your email account; an account activation '. 'message has been sent.'); //Config file has been written $this->assertTrue(file_exists($THINKUP_CFG['source_root_path']. 'webapp/test_installer/thinkup/config.inc.php')); //Test bad activation code $this->get($this->url.'/test_installer/thinkup/session/activate.php?usr=user@example.com&code=dummycode'); //$this->showText(); $this->assertText('Houston, we have a problem: Account activation failed.'); //Get activation code for user from database date_default_timezone_set('America/Los_Angeles'); $owner_dao = new OwnerMySQLDAO(); $code = $owner_dao->getActivationCode('*****@*****.**'); $activation_code = $code['activation_code']; //Visit activation page $this->get($this->url.'/test_installer/thinkup/session/activate.php?usr=user@example.com&code='. $activation_code); $this->assertNoText('Houston, we have a problem: Account activation failed.'); $this->assertText('Success! Your account has been activated. Please log in.'); //Log into ThinkUp $this->clickLink('Log in'); $this->setField('email', '*****@*****.**'); $this->setField('pwd', 'secret'); $this->click("Log In"); $this->assertText('You have no accounts configured. Set up an account now'); //Visit Configuration/Settings page and assert content there if (floatval($version) >= 0.6) { $this->click("Settings"); //link name changed in beta 6 } else { $this->click("Configuration"); } $this->assertTitle('Configure Your Account | ThinkUp'); $this->assertText('As an administrator you can configure all installed plugins.'); // run updates and migrations require 'tests/migration-assertions.php'; // build latest version for testing $migration_sql_dir = THINKUP_ROOT_PATH . 'webapp/install/sql/mysql_migrations/'; $latest_migration_file = false; $config = Config::getInstance(); $current_version = $config->getValue('THINKUP_VERSION'); $latest_migration = glob($migration_sql_dir . '*_v' . $LATEST_VERSION .'.sql.migration'); if($LATEST_VERSION == $current_version) { $this->debug("Building zip for latest version: $LATEST_VERSION"); $sql_files = glob($migration_sql_dir . '*.sql'); if (sizeof($sql_files) > 0) { $this->debug("found sql update for latest version $LATEST_VERSION: $sql_files[0]"); if(! isset($latest_migration[0])) { $date_stamp = date("Y-m-d"); $latest_migration_file = $migration_sql_dir . $date_stamp . '_v' . $LATEST_VERSION . '.sql.migration'; $fp = fopen($latest_migration_file, 'w'); $sql_files = glob($migration_sql_dir . '*.sql'); $sql_file = $sql_files[0]; $sql_migration = file_get_contents($sql_file); fwrite($fp, " -- migration file " . $sql_file . "\n\n"); fwrite($fp, $sql_migration); fwrite($fp, "\n\n--"); fclose($fp); } } exec('extras/scripts/generate-distribution'); exec('cp build/thinkup.zip build/' . $LATEST_VERSION . '.zip'); if(file_exists($latest_migration_file)) { unlink( $latest_migration_file ); } } return array('MIGRATIONS' => $MIGRATIONS, 'latest_migration_file' => $latest_migration_file ); }
public function testPromoteToAdmin() { $config = Config::getInstance(); $config_array = $config->getValuesArray(); $dao = new OwnerMySQLDAO($config_array); $this->assertFalse($dao->doesAdminExist()); $result = $dao->promoteToAdmin('*****@*****.**'); $this->assertEqual($result, 1); //one row updated $this->assertTrue($dao->doesAdminExist()); }
/** * Sets up initial app */ private function setUpApp($version, $MIGRATIONS) { // run updates and migrations require 'tests/migration-assertions.php'; $this->debug("Setting up base install for upgrade: {$version}"); $zip_url = $MIGRATIONS[$version]['zip_url']; require THINKUP_WEBAPP_PATH . 'config.inc.php'; //install beta 1 $zipfile = $this->getInstall($zip_url, $version, $this->installs_dir); //Extract into test_installer directory and set necessary folder permissions exec('cp ' . $zipfile . ' webapp/test_installer/.;' . 'cd webapp/test_installer/;' . 'unzip ' . $zipfile . ';chmod -R 777 thinkup'); //Config file doesn't exist $this->assertFalse(file_exists($THINKUP_CFG['source_root_path'] . 'webapp/test_installer/thinkup/config.inc.php')); //Set test mode $this->get($this->url . '/test_installer/thinkup/install/setmode.php?m=tests'); //Include config again to get test db credentials require THINKUP_WEBAPP_PATH . 'config.inc.php'; //$this->showText(); //Start installation process $this->get($this->url . '/test_installer/thinkup/'); $this->assertTitle("ThinkUp"); $this->assertText('ThinkUp\'s configuration file does not exist! Try installing ThinkUp.'); $this->clickLink("installing ThinkUp."); $this->assertText('Great! Your system has everything it needs to run ThinkUp.'); //Set test mode putenv("MODE=TESTS"); //Include config again to get test db credentials require THINKUP_WEBAPP_PATH . 'config.inc.php'; $this->get('index.php?step=2'); $this->assertText('Create Your ThinkUp Account'); $this->setField('full_name', 'ThinkUp J. User'); $this->setField('site_email', '*****@*****.**'); $this->setField('password', 'secret123'); $this->setField('confirm_password', 'secret123'); $this->setField('timezone', 'America/Los_Angeles'); $this->setField('db_host', $THINKUP_CFG['db_host']); $this->setField('db_name', $THINKUP_CFG['db_name']); $this->setField('db_user', $THINKUP_CFG['db_user']); $this->setField('db_passwd', $THINKUP_CFG['db_password']); $this->setField('db_socket', $THINKUP_CFG['db_socket']); $this->clickSubmitByName('Submit'); $this->assertText('ThinkUp has been installed successfully. Check your email account; an account activation ' . 'message has been sent.'); //Config file has been written $this->assertTrue(file_exists($THINKUP_CFG['source_root_path'] . 'webapp/test_installer/thinkup/config.inc.php')); //Test bad activation code $this->get($this->url . '/test_installer/thinkup/session/activate.php?usr=user@example.com&code=dummycode'); //$this->showText(); $this->assertText('Houston, we have a problem: Account activation failed.'); //Get activation code for user from database Utils::setDefaultTimezonePHPini(); $owner_dao = new OwnerMySQLDAO(); $code = $owner_dao->getActivationCode('*****@*****.**'); $activation_code = $code['activation_code']; //Visit activation page $this->get($this->url . '/test_installer/thinkup/session/activate.php?usr=user@example.com&code=' . $activation_code); $this->assertNoText('Houston, we have a problem: Account activation failed.'); $this->assertText('Success! Your account has been activated. Please log in.'); //Log into ThinkUp $this->clickLink('Log in'); $this->setField('email', '*****@*****.**'); $this->setField('pwd', 'secret123'); $this->click("Log In"); if (version_compare($version, '0.17', '>=')) { $this->assertText('Add a Twitter Account'); $this->assertText('Add a Facebook Account'); $this->assertText('Add a Google+ Account'); $this->assertText('Adjust Your Settings'); } if (version_compare($version, '0.16', '>=')) { $this->assertText('Welcome to ThinkUp. Let\'s get started.'); } else { $this->assertText('You have no'); //accounts/services configured. Set up an account now'); $this->assertText('Set up'); //an account/a service like Twitter or Facebook now } //Visit Configuration/Settings page and assert content there if (version_compare($version, '0.6', '>=')) { $this->click("Settings"); //link name changed in beta 6 $this->debug("Clicked Settings"); } else { $this->click("Configuration"); $this->debug("Clicked Configuration"); } $this->assertTitle('Configure Your Account | ThinkUp'); $this->assertText('admin'); // run updates and migrations require 'tests/migration-assertions.php'; // build latest version for testing $migration_sql_dir = THINKUP_ROOT_PATH . 'webapp/install/sql/mysql_migrations/'; $latest_migration_file = false; $config = Config::getInstance(); $current_version = $config->getValue('THINKUP_VERSION'); $latest_migration = glob($migration_sql_dir . '*_v' . $LATEST_VERSION . '.sql.migration'); if ($LATEST_VERSION == $current_version && $this->latest_build_made == false) { $this->debug("Building zip for latest version: {$LATEST_VERSION}"); exec('extras/scripts/generate-distribution'); exec('cp build/thinkup.zip build/' . $LATEST_VERSION . '.zip'); if (file_exists($latest_migration_file)) { unlink($latest_migration_file); } $this->latest_build_made = true; } return array('MIGRATIONS' => $MIGRATIONS, 'latest_migration_file' => $latest_migration_file); }
public function testFailedLoginLockout() { $session = new Session(); $cryptpass = $session->pwdcrypt("blah"); $owner = array('id'=>2, 'email'=>'*****@*****.**', 'pwd'=>$cryptpass, 'is_activated'=>1); $builder = FixtureBuilder::build('owners', $owner); //force login lockout by providing the wrong password more than 10 times $i = 1; while ($i <= 15) { $_POST['Submit'] = 'Log In'; $_POST['email'] = '*****@*****.**'; $_POST['pwd'] = 'blah1'; $controller = new LoginController(true); $results = $controller->go(); $v_mgr = $controller->getViewManager(); $this->assertEqual($v_mgr->getTemplateDataItem('controller_title'), 'Log in'); if ($i <= 11) { $this->assertPattern("/Incorrect password/", $v_mgr->getTemplateDataItem('errormsg')); $owner_dao = new OwnerMySQLDAO(); $owner = $owner_dao->getByEmail('*****@*****.**'); $this->assertEqual($owner->failed_logins, $i); } else { $this->assertEqual("Inactive account. Account deactivated due to too many failed logins. ". '<a href="forgot.php">Reset your password.</a>', $v_mgr->getTemplateDataItem('errormsg')); $owner_dao = new OwnerMySQLDAO(); $owner = $owner_dao->getByEmail('*****@*****.**'); $this->assertEqual($owner->account_status, "Account deactivated due to too many failed logins"); } $i = $i + 1; } }
public function testSetOwnerAdmin() { $builders_array = array(); // build our data $builders_array[] = FixtureBuilder::build('owners', array('full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 0, 'is_admin' => 0)); $builders_array[] = FixtureBuilder::build('owners', array('full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 1, 'is_admin' => 1)); // init our dao $dao = new OwnerMySQLDAO(); // flip form false to true $test_owners_records = $builders_array[0]->columns; $id = $test_owners_records['last_insert_id']; $this->assertTrue($dao->setOwnerAdmin($id, 1)); $owner = $this->DAO->getByEmail('*****@*****.**'); //new status $this->assertTrue($owner->is_admin); // already true $test_owners_records = $builders_array[1]->columns; $id = $test_owners_records['last_insert_id']; // nothing updated, so false $this->assertFalse($dao->setOwnerAdmin($id, 1)); $owner = $this->DAO->getByEmail('*****@*****.**'); //new status $this->assertTrue($owner->is_admin); // flip to false $test_owners_records = $builders_array[0]->columns; $id = $test_owners_records['last_insert_id']; $this->assertTrue($dao->setOwnerAdmin($id, 0)); $owner = $this->DAO->getByEmail('*****@*****.**'); //new status $this->assertFalse($owner->is_admin); }
public function testAuthControlLoggedInTimeZone() { $owner_dao = new OwnerMySQLDAO(); $owner = $owner_dao->getByEmail('*****@*****.**'); $this->assertEqual('UTC', $owner->timezone); $this->simulateLogin('*****@*****.**', false, true); $_POST['updatepreferences'] = 'Update'; $_POST['timezone'] = 'America/New_York'; $controller = new AccountConfigurationController(true); $controller->go(); $owner = $owner_dao->getByEmail('*****@*****.**'); // No CSRF shouldn't update $this->assertNotEqual('America/NewYork', $owner->timezone); $this->simulateLogin('*****@*****.**', false, true); $_POST['updatepreferences'] = 'Update'; $_POST['timezone'] = 'bananas'; $_POST['csrf_token'] = parent::CSRF_TOKEN; $controller = new AccountConfigurationController(true); $output = $controller->go(); $owner = $owner_dao->getByEmail('*****@*****.**'); // bad value, shouldn't update $this->assertNotEqual('bananas', $owner->timezone); $this->assertEqual('UTC', $owner->timezone); $this->assertNoPattern('/time zone has been saved/', $output); $this->simulateLogin('*****@*****.**', false, true); $_POST['updatepreferences'] = 'Update'; $_POST['timezone'] = 'America/New_York'; $_POST['csrf_token'] = parent::CSRF_TOKEN; $controller = new AccountConfigurationController(true); $output = $controller->go(); $owner = $owner_dao->getByEmail('*****@*****.**'); $this->assertNotEqual('UTC', $owner->timezone); $this->assertEqual('America/New_York', $owner->timezone); $this->assertPattern('/time zone has been saved/', $output); }
public function testAuthControlLoggedInChangeNotificationFrequency() { $owner_dao = new OwnerMySQLDAO(); $owner = $owner_dao->getByEmail('*****@*****.**'); $this->assertEqual('daily', $owner->email_notification_frequency); $this->simulateLogin('*****@*****.**', false, true); $controller = new AccountConfigurationController(true); $output = $controller->go(); $this->assertPattern('/"daily"[^>]*selected/', $output); $this->assertNoPattern('/"both"[^>]*selected/', $output); $this->simulateLogin('*****@*****.**', false, true); $_POST['updatefrequency'] = 'Update Frequency'; $_POST['notificationfrequency'] = 'both'; $controller = new AccountConfigurationController(true); $controller->go(); $owner = $owner_dao->getByEmail('*****@*****.**'); // No CSRF shouldn't update $this->assertNotEqual('both', $owner->email_notification_frequency); $this->simulateLogin('*****@*****.**', false, true); $_POST['updatefrequency'] = 'Update Frequency'; $_POST['notificationfrequency'] = 'bananas'; $_POST['csrf_token'] = parent::CSRF_TOKEN; $controller = new AccountConfigurationController(true); $output = $controller->go(); $owner = $owner_dao->getByEmail('*****@*****.**'); // bad value, shouldn't update $this->assertNotEqual('bananas', $owner->email_notification_frequency); $this->assertEqual('daily', $owner->email_notification_frequency); $this->assertNoPattern('/email notification frequency has been updated/', $output); $this->simulateLogin('*****@*****.**', false, true); $_POST['updatefrequency'] = 'Update Frequency'; $_POST['notificationfrequency'] = 'both'; $_POST['csrf_token'] = parent::CSRF_TOKEN; $controller = new AccountConfigurationController(true); $output = $controller->go(); $owner = $owner_dao->getByEmail('*****@*****.**'); $this->assertNotEqual('daily', $owner->email_notification_frequency); $this->assertEqual('both', $owner->email_notification_frequency); $this->assertNoPattern('/"daily"[^>]*selected/', $output); $this->assertPattern('/"both"[^>]*selected/', $output); $this->assertPattern('/email notification frequency has been updated/', $output); }
public function testSetOwnerActive() { $builders_array = array(); # build our data $builders_array[] = FixtureBuilder::build('owners', array('full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 0)); $builders_array[] = FixtureBuilder::build('owners', array('full_name' => 'ThinkUp J. User', 'email' => '*****@*****.**', 'is_activated' => 1)); # init our dao $dao = new OwnerMySQLDAO(); // flip form false to true $test_owners_records = $builders_array[0]->columns; $id = $test_owners_records['last_insert_id']; $this->assertTrue($dao->setOwnerActive($id, 1)); $owner = $this->DAO->getByEmail('*****@*****.**'); //new status $this->assertTrue($owner->is_activated); // $sql = "select * from " . $this->prefix . 'owners where id = ' . $test_owners_records['last_insert_id']; // $stmt = OwnerMysqlDAO::$PDO->query($sql); // $data = $stmt->fetch(); // $this->assertEqual($data['is_activated'], 1); // already true $test_owners_records = $builders_array[1]->columns; $id = $test_owners_records['last_insert_id']; // nothing updated, so false $this->assertFalse($dao->setOwnerActive($id, 1)); $owner = $this->DAO->getByEmail('*****@*****.**'); //new status $this->assertTrue($owner->is_activated); // $sql = "select * from " . $this->prefix . 'owners where id = ' . $test_owners_records['last_insert_id']; // $stmt = OwnerMysqlDAO::$PDO->query($sql); // $data = $stmt->fetch(); // $this->assertEqual($data['is_activated'], 1); // flip to false $test_owners_records = $builders_array[0]->columns; $id = $test_owners_records['last_insert_id']; $this->assertTrue($dao->setOwnerActive($id, 0)); $owner = $this->DAO->getByEmail('*****@*****.**'); //new status $this->assertFalse($owner->is_activated); // $sql = "select * from " . $this->prefix . 'owners where id = ' . $test_owners_records['last_insert_id']; // $stmt = OwnerMysqlDAO::$PDO->query($sql); // $data = $stmt->fetch(); // $this->assertEqual($data['is_activated'], 0); }
public function testSuccessfulInstallationAndAccountActivation() { require THINKUP_WEBAPP_PATH.'config.inc.php'; global $TEST_DATABASE; //Config file doesn't exist $this->assertFalse(file_exists($THINKUP_CFG['source_root_path']. 'webapp/test_installer/thinkup/config.inc.php')); //Start installation process $this->get($this->url.'/test_installer/thinkup/'); $this->assertTitle("ThinkUp"); $this->assertText('ThinkUp\'s configuration file does not exist! Try installing ThinkUp.'); $this->clickLink("installing ThinkUp."); $this->assertText('Great! Your system has everything it needs to run ThinkUp. You may proceed to the next '. 'step.'); $this->clickLinkById('nextstep'); $this->assertText('Create Your ThinkUp Account'); $this->setField('full_name', 'ThinkUp J. User'); $this->setField('site_email', '*****@*****.**'); $this->setField('password', 'secret'); $this->setField('confirm_password', 'secret'); $this->setField('timezone', 'America/Los_Angeles'); $this->setField('db_host', $THINKUP_CFG['db_host']); $this->setField('db_name', $TEST_DATABASE); $this->setField('db_user', $THINKUP_CFG['db_user']); $this->setField('db_passwd', $THINKUP_CFG['db_password']); $this->setField('db_socket', $THINKUP_CFG['db_socket']); $this->clickSubmitByName('Submit'); $this->assertText('ThinkUp has been installed successfully. Check your email account; an account activation '. 'message has been sent.'); //Config file has been written $this->assertTrue(file_exists($THINKUP_CFG['source_root_path']. 'webapp/test_installer/thinkup/config.inc.php')); //Test bad activation code $this->get($this->url.'/test_installer/thinkup/session/activate.php?usr=user@example.com&code=dummycode'); $this->assertText('Houston, we have a problem: Account activation failed.'); //Get activation code for user from database date_default_timezone_set('America/Los_Angeles'); $owner_dao = new OwnerMySQLDAO(); $code = $owner_dao->getActivationCode('*****@*****.**'); $activation_code = $code['activation_code']; //Visit activation page $this->get($this->url.'/test_installer/thinkup/session/activate.php?usr=user@example.com&code='. $activation_code); $this->assertNoText('Houston, we have a problem: Account activation failed.'); $this->assertText('Success! Your account has been activated. Please log in.'); //Log into ThinkUp $this->clickLink('Log in'); $this->setField('email', '*****@*****.**'); $this->setField('pwd', 'secret'); $this->click("Log In"); $this->assertText('You have no accounts configured. Set up an account now'); //Visit Settings page and assert content there $this->click("Settings"); $this->assertTitle('Configure Your Account | ThinkUp'); $this->assertText('As an administrator you can configure all installed plugins.'); }