Merge pull request #389 from kijin/develop

유닛 테스트 정리 및 오류 수정
This commit is contained in:
Kijin Sung 2016-03-20 17:10:46 +09:00
commit 3ee49c98cc
8 changed files with 20 additions and 16 deletions

View file

@ -16,9 +16,9 @@ before_script:
- if [[ $TRAVIS_PHP_VERSION == "5.4" ]]; then wget http://codeception.com/releases/2.0.16/codecept.phar; fi - if [[ $TRAVIS_PHP_VERSION == "5.4" ]]; then wget http://codeception.com/releases/2.0.16/codecept.phar; fi
- if [[ ! -f codecept.phar ]]; then wget http://codeception.com/releases/2.1.6/codecept.phar; fi - if [[ ! -f codecept.phar ]]; then wget http://codeception.com/releases/2.1.6/codecept.phar; fi
script: script:
- if [[ -f codecept.phar ]]; then php codecept.phar build; fi - if [[ -s codecept.phar ]]; then php codecept.phar build; fi
- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi - if [[ -s codecept.phar && $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi
- if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi - if [[ -s codecept.phar && $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi
- grunt lint - grunt lint
notifications: notifications:
email: false email: false

View file

@ -1063,7 +1063,11 @@ class Context
*/ */
public static function convertEncodingStr($str) public static function convertEncodingStr($str)
{ {
if(!$str) return null; if (!$str || utf8_check($str))
{
return $str;
}
$obj = new stdClass; $obj = new stdClass;
$obj->str = $str; $obj->str = $str;
$obj = self::convertEncoding($obj); $obj = self::convertEncoding($obj);

View file

@ -67,7 +67,8 @@ class DBMysql extends DB
$result = @mysql_connect($connection['host'], $connection['user'], $connection['pass']); $result = @mysql_connect($connection['host'], $connection['user'], $connection['pass']);
if(!$result) if(!$result)
{ {
exit('Unable to connect to DB.'); $this->setError(-1, 'Unable to connect to DB.');
return;
} }
if(mysql_error()) if(mysql_error())
@ -164,7 +165,8 @@ class DBMysql extends DB
{ {
if(!$connection) if(!$connection)
{ {
exit('Rhymix cannot handle DB connection.'); $this->setError(-1, 'Unable to connect to DB.');
return false;
} }
// Run the query statement // Run the query statement
$result = @mysql_query($query, $connection); $result = @mysql_query($query, $connection);

View file

@ -80,8 +80,8 @@ class DBMysqli extends DBMysql
{ {
if ($connection === null) if ($connection === null)
{ {
debug_print_backtrace(); $this->setError(-1, 'Unable to connect to DB.');
exit; return false;
} }
if($this->use_prepared_statements == 'Y') if($this->use_prepared_statements == 'Y')
{ {

View file

@ -218,7 +218,7 @@ class Password
{ {
$salt = Security::getRandom(12, 'alnum'); $salt = Security::getRandom(12, 'alnum');
$hash_algorithm = 'sha512'; $hash_algorithm = 'sha512';
$iterations = pow(2, self::getWorkFactor() + 5); $iterations = intval(pow(2, self::getWorkFactor() + 5)) ?: 16384;
$key_length = 24; $key_length = 24;
} }
else else
@ -226,7 +226,7 @@ class Password
$parts = explode(':', $salt); $parts = explode(':', $salt);
$salt = $parts[2]; $salt = $parts[2];
$hash_algorithm = $parts[0]; $hash_algorithm = $parts[0];
$iterations = $parts[1]; $iterations = intval($parts[1], 10);
$key_length = strlen(base64_decode($parts[3])); $key_length = strlen(base64_decode($parts[3]));
} }
return self::pbkdf2($hashchain, $salt, $hash_algorithm, $iterations, $key_length); return self::pbkdf2($hashchain, $salt, $hash_algorithm, $iterations, $key_length);

View file

@ -339,7 +339,7 @@ class Storage
try try
{ {
$iterator = new \FilesystemIterator($dirname, \FilesystemIterator::CURRENT_AS_PATHNAME); $iterator = new \FilesystemIterator($dirname, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS);
} }
catch (\UnexpectedValueException $e) catch (\UnexpectedValueException $e)
{ {

View file

@ -38,11 +38,9 @@ class TimerTest extends \Codeception\TestCase\Test
function testMultipleTimers() function testMultipleTimers()
{ {
$t1 = Rhymix\Framework\Timer::start('timer1'); $t1 = Rhymix\Framework\Timer::start('timer1');
usleep(5000); usleep(10000);
$t2 = Rhymix\Framework\Timer::start('timer2'); $t2 = Rhymix\Framework\Timer::start('timer2');
usleep(1000);
$t3 = Rhymix\Framework\Timer::stop('timer1'); $t3 = Rhymix\Framework\Timer::stop('timer1');
usleep(2000);
$t4 = Rhymix\Framework\Timer::stop('timer2'); $t4 = Rhymix\Framework\Timer::stop('timer2');
$this->assertGreaterThanOrEqual($t1, $t2); $this->assertGreaterThanOrEqual($t1, $t2);
@ -52,7 +50,7 @@ class TimerTest extends \Codeception\TestCase\Test
function testTimerFormat() function testTimerFormat()
{ {
$t1 = Rhymix\Framework\Timer::start(); $t1 = Rhymix\Framework\Timer::start();
usleep(1000); usleep(10000);
$t2 = Rhymix\Framework\Timer::stopFormat(); $t2 = Rhymix\Framework\Timer::stopFormat();
$this->assertRegexp('/^[0-9\.,]+ms$/', $t2); $this->assertRegexp('/^[0-9\.,]+ms$/', $t2);

View file

@ -22,7 +22,7 @@ class LegacyTest extends \Codeception\TestCase\Test
public function testGetNextSequence() public function testGetNextSequence()
{ {
if (!file_exists(\RX_BASEDIR . 'files/config/config.php')) if (!DB::getInstance()->isConnected())
{ {
return; return;
} }