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'); }
/** * 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); }
/** * 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 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.'); }