CI codeception 자동설치 테스트 추가

This commit is contained in:
bnu 2015-05-28 14:15:00 +09:00
parent d1916d744f
commit 5cc8f55a64
7 changed files with 410 additions and 7 deletions

View file

@ -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/'

View file

@ -0,0 +1,64 @@
<?php
use \Codeception\Configuration;
$I = new InstallTester($scenario);
$config = (!$this->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');

View file

@ -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');

View file

@ -1,4 +1,4 @@
<?php //[STAMP] 8e0df11a46642efe1cdbcd6ea0a22ad0
<?php //[STAMP] 655f3852f47c53f31093f448f1b7f2c5
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
@ -9,6 +9,7 @@ use Codeception\Module\Db;
use Codeception\Module\PhpBrowser;
use Codeception\Module\DbDropTablesHelper;
use Codeception\Module\InstallHelper;
use Codeception\Module\Filesystem;
/**
* Inherited Methods
@ -2096,4 +2097,337 @@ class InstallTester extends \Codeception\Actor
public function cleanup() {
return $this->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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
* <?php
* $I->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()));
}
}

View file

@ -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();

View file

@ -1,10 +1,12 @@
<?php
namespace Codeception\Module;
use Codeception\Util\FileSystem;
class InstallHelper extends \Codeception\Module
{
public function _initialize()
public function _before()
{
\Codeception\Util\FileSystem::deleteDir('files');
FileSystem::deleteDir('files');
}
}

View file

@ -1,4 +1,4 @@
<?php //[STAMP] 12ed79a2e487867b140068ed6d5a381b
<?php //[STAMP] bd6b55949e6a72559e6ee503e29432bb
// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build