diff --git a/tests/Install.suite.dist.yml b/tests/Install.suite.dist.yml index c24bfbd37..b217a1c35 100644 --- a/tests/Install.suite.dist.yml +++ b/tests/Install.suite.dist.yml @@ -1,6 +1,6 @@ class_name: InstallTester modules: - enabled: [Db, PhpBrowser, DbDropTablesHelper, InstallHelper] + enabled: [Db, PhpBrowser, DbDropTablesHelper, InstallHelper, Filesystem] config: PhpBrowser: url: 'http://localhost:8000/' diff --git a/tests/Install/AutoinstallCept.php b/tests/Install/AutoinstallCept.php new file mode 100644 index 000000000..a5cd05bd2 --- /dev/null +++ b/tests/Install/AutoinstallCept.php @@ -0,0 +1,64 @@ +env) ? Configuration::suiteSettings('Install', Configuration::config()) : Configuration::suiteEnvironments('Install')[$this->env]; + +$db_config = $config['modules']['config']['Db']; + +$dsn = $db_config['dsn']; +$dsn = split('[;:]', $dsn); +$db_type = array_shift($dsn); +$dbinfo = [ + 'type' => $db_type, + 'user' => $db_config['user'], + 'password' => $db_config['password'], + 'port' => ((isset($db_config['port']) && $db_config['port'])?: 3306), +]; +foreach($dsn as $piece) { + list($key, $val) = explode('=', $piece); + $dbinfo[$key] = $val; +} + +$install_config = array( + 'db_type' => $dbinfo['type'], + 'db_port' => $dbinfo['port'], + 'db_hostname' => $dbinfo['host'], + 'db_userid' => $dbinfo['user'], + 'db_password' => $dbinfo['password'], + 'db_database' => $dbinfo['dbname'], + 'db_table_prefix' =>'xe_', + 'use_rewrite' =>'N', + 'time_zone' =>'0900', + 'email_address' =>'admin@admin.net', + 'password' =>'admin', + 'password2' =>'admin', + 'nick_name' =>'admin', + 'user_id' =>'admin', + 'lang_type' => 'ko', +); + +$install_config = '<' . '?php $install_config = ' . var_export($install_config, true) . ';'; + +$I->wantTo('auto install'); +$I->writeToFile(_XE_PATH_ . 'config/install.config.php', $install_config); +$I->amOnPage('/'); + +$I->wantTo('completed'); +$I->dontSeeElement('//div[@id="progress"]/ul/li'); +$I->amOnPage('/index.php?act=dispMemberLoginForm'); + +$I->fillField('user_id', 'admin@admin.net'); +$I->submitForm('.login-body form', [ + 'act' => 'procMemberLogin', + 'user_id' => 'admin@admin.net', + 'password' => 'admin', + 'success_return_url' => '/index.php?module=admin' +]); + +$I->seeInCurrentUrl('module=admin'); +$I->seeElement('#gnbNav'); +$I->seeElement('#content .x_page-header'); +$I->see('설치 환경 수집 동의', 'h2'); + diff --git a/tests/Install/InstallCept.php b/tests/Install/InstallCept.php index 4a0621535..a3e5750b7 100644 --- a/tests/Install/InstallCept.php +++ b/tests/Install/InstallCept.php @@ -22,6 +22,10 @@ foreach($dsn as $piece) { $dbinfo[$key] = $val; } +if(\Filehandler::exists(_XE_PATH_ . 'config/install.config.php')) { + $I->deleteFile(_XE_PATH_ . 'config/install.config.php'); +} + // Step 1 $I->wantTo('Install XE Core'); $I->amOnPage('/index.php?l=ko'); @@ -85,7 +89,6 @@ $I->submitForm('#content form', [ ]); // Step 9 -$I->wantTo('completed'); $I->dontSeeElement('//div[@id="progress"]/ul/li'); $I->amOnPage('/index.php?act=dispMemberLoginForm'); diff --git a/tests/Install/InstallTester.php b/tests/Install/InstallTester.php index 5d2e8626a..1e1aef6fa 100644 --- a/tests/Install/InstallTester.php +++ b/tests/Install/InstallTester.php @@ -1,4 +1,4 @@ -scenario->runStep(new \Codeception\Step\Action('cleanup', func_get_args())); } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Enters a directory In local filesystem. + * Project root directory is used by default + * + * @param $path + * @see \Codeception\Module\Filesystem::amInPath() + */ + public function amInPath($path) { + return $this->scenario->runStep(new \Codeception\Step\Condition('amInPath', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Opens a file and stores it's content. + * + * Usage: + * + * ``` php + * openFile('composer.json'); + * $I->seeInThisFile('codeception/codeception'); + * ?> + * ``` + * + * @param $filename + * @see \Codeception\Module\Filesystem::openFile() + */ + public function openFile($filename) { + return $this->scenario->runStep(new \Codeception\Step\Action('openFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Deletes a file + * + * ``` php + * deleteFile('composer.lock'); + * ?> + * ``` + * + * @param $filename + * @see \Codeception\Module\Filesystem::deleteFile() + */ + public function deleteFile($filename) { + return $this->scenario->runStep(new \Codeception\Step\Action('deleteFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Deletes directory with all subdirectories + * + * ``` php + * deleteDir('vendor'); + * ?> + * ``` + * + * @param $dirname + * @see \Codeception\Module\Filesystem::deleteDir() + */ + public function deleteDir($dirname) { + return $this->scenario->runStep(new \Codeception\Step\Action('deleteDir', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Copies directory with all contents + * + * ``` php + * copyDir('vendor','old_vendor'); + * ?> + * ``` + * + * @param $src + * @param $dst + * @see \Codeception\Module\Filesystem::copyDir() + */ + public function copyDir($src, $dst) { + return $this->scenario->runStep(new \Codeception\Step\Action('copyDir', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks If opened file has `text` in it. + * + * Usage: + * + * ``` php + * openFile('composer.json'); + * $I->seeInThisFile('codeception/codeception'); + * ?> + * ``` + * + * @param $text + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Filesystem::seeInThisFile() + */ + public function canSeeInThisFile($text) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeInThisFile', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks If opened file has `text` in it. + * + * Usage: + * + * ``` php + * openFile('composer.json'); + * $I->seeInThisFile('codeception/codeception'); + * ?> + * ``` + * + * @param $text + * @see \Codeception\Module\Filesystem::seeInThisFile() + */ + public function seeInThisFile($text) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeInThisFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks the strict matching of file contents. + * Unlike `seeInThisFile` will fail if file has something more than expected lines. + * Better to use with HEREDOC strings. + * Matching is done after removing "\r" chars from file content. + * + * ``` php + * openFile('process.pid'); + * $I->seeFileContentsEqual('3192'); + * ?> + * ``` + * + * @param $text + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Filesystem::seeFileContentsEqual() + */ + public function canSeeFileContentsEqual($text) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileContentsEqual', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks the strict matching of file contents. + * Unlike `seeInThisFile` will fail if file has something more than expected lines. + * Better to use with HEREDOC strings. + * Matching is done after removing "\r" chars from file content. + * + * ``` php + * openFile('process.pid'); + * $I->seeFileContentsEqual('3192'); + * ?> + * ``` + * + * @param $text + * @see \Codeception\Module\Filesystem::seeFileContentsEqual() + */ + public function seeFileContentsEqual($text) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileContentsEqual', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks If opened file doesn't contain `text` in it + * + * ``` php + * openFile('composer.json'); + * $I->dontSeeInThisFile('codeception/codeception'); + * ?> + * ``` + * + * @param $text + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Filesystem::dontSeeInThisFile() + */ + public function cantSeeInThisFile($text) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeInThisFile', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks If opened file doesn't contain `text` in it + * + * ``` php + * openFile('composer.json'); + * $I->dontSeeInThisFile('codeception/codeception'); + * ?> + * ``` + * + * @param $text + * @see \Codeception\Module\Filesystem::dontSeeInThisFile() + */ + public function dontSeeInThisFile($text) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeInThisFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Deletes a file + * @see \Codeception\Module\Filesystem::deleteThisFile() + */ + public function deleteThisFile() { + return $this->scenario->runStep(new \Codeception\Step\Action('deleteThisFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if file exists in path. + * Opens a file when it's exists + * + * ``` php + * seeFileFound('UserModel.php','app/models'); + * ?> + * ``` + * + * @param $filename + * @param string $path + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Filesystem::seeFileFound() + */ + public function canSeeFileFound($filename, $path = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('seeFileFound', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if file exists in path. + * Opens a file when it's exists + * + * ``` php + * seeFileFound('UserModel.php','app/models'); + * ?> + * ``` + * + * @param $filename + * @param string $path + * @see \Codeception\Module\Filesystem::seeFileFound() + */ + public function seeFileFound($filename, $path = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('seeFileFound', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if file does not exists in path + * + * @param $filename + * @param string $path + * Conditional Assertion: Test won't be stopped on fail + * @see \Codeception\Module\Filesystem::dontSeeFileFound() + */ + public function cantSeeFileFound($filename, $path = null) { + return $this->scenario->runStep(new \Codeception\Step\ConditionalAssertion('dontSeeFileFound', func_get_args())); + } + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Checks if file does not exists in path + * + * @param $filename + * @param string $path + * @see \Codeception\Module\Filesystem::dontSeeFileFound() + */ + public function dontSeeFileFound($filename, $path = null) { + return $this->scenario->runStep(new \Codeception\Step\Assertion('dontSeeFileFound', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Erases directory contents + * + * ``` php + * cleanDir('logs'); + * ?> + * ``` + * + * @param $dirname + * @see \Codeception\Module\Filesystem::cleanDir() + */ + public function cleanDir($dirname) { + return $this->scenario->runStep(new \Codeception\Step\Action('cleanDir', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Saves contents to file + * + * @param $filename + * @param $contents + * @see \Codeception\Module\Filesystem::writeToFile() + */ + public function writeToFile($filename, $contents) { + return $this->scenario->runStep(new \Codeception\Step\Action('writeToFile', func_get_args())); + } } diff --git a/tests/_bootstrap.php b/tests/_bootstrap.php index a778b4088..21bf1735c 100644 --- a/tests/_bootstrap.php +++ b/tests/_bootstrap.php @@ -2,7 +2,7 @@ // This is global bootstrap for autoloading if(!defined('__XE__')) define('__XE__', true); if(!defined('_XE_PATH_')) define('_XE_PATH_', realpath(dirname(__FILE__).'/../').'/'); -error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_WARNING ^ E_STRICT); +require_once _XE_PATH_.'config/config.inc.php'; function _debug() { $args = func_get_args(); diff --git a/tests/_support/InstallHelper.php b/tests/_support/InstallHelper.php index ba92cf656..77cd8f985 100644 --- a/tests/_support/InstallHelper.php +++ b/tests/_support/InstallHelper.php @@ -1,10 +1,12 @@