Fix unit tests for validator

This commit is contained in:
Kijin Sung 2016-02-18 09:12:32 +09:00
parent 1a3c500c76
commit 4ec179372a
3 changed files with 21 additions and 16 deletions

View file

@ -476,6 +476,7 @@ class Context
}
if (!count($config))
{
self::$_instance->db_info = self::$_instance->db_info ?: new stdClass;
return;
}

View file

@ -1,20 +1,11 @@
<?php
require_once _XE_PATH_.'classes/context/Context.class.php';
require_once _XE_PATH_.'classes/xml/XmlParser.class.php';
require_once _XE_PATH_.'classes/handler/Handler.class.php';
require_once _XE_PATH_.'classes/file/FileHandler.class.php';
require_once _XE_PATH_.'classes/validator/Validator.class.php';
class ValidatorTest extends \Codeception\TestCase\Test
{
public function _before()
{
global $lang;
if(!$lang) $lang = new stdClass();
$lang->filter = new stdClass();
$lang->filter->isnull = 'isnull';
$lang->filter->outofrange = 'outofrange';
$lang->filter->equalto = 'equalto';
$oContext = Context::getInstance();
$oContext->init();
}
public function testRequired()
@ -187,7 +178,7 @@ class ValidatorTest extends \Codeception\TestCase\Test
// javascript
$vd->setCacheDir(__DIR__ . '/validator');
$js = $vd->getJsPath();
$this->assertFileEquals($js, __DIR__ . '/validator/condition.en.js');
$this->assertEquals(trim(file_get_contents(__DIR__ . '/validator/condition.en.js')), trim(file_get_contents($js)));
}
protected function tearDown()

View file

@ -2,7 +2,20 @@
v=xe.getApp('validator')[0];if(!v)return;
v.cast('ADD_FILTER',['condition', {'greeting1':{required:true},'greeting2':{'if':[{test:'$greeting1 == \'Hello\'', attr:'required', value:'true'}]}}]);
v.cast('ADD_MESSAGE',['isnull','isnull']);
v.cast('ADD_MESSAGE',['outofrange','outofrange']);
v.cast('ADD_MESSAGE',['equalto','equalto']);
})(jQuery);
v.cast('ADD_MESSAGE',['isnull','%s 값은 필수입니다.']);
v.cast('ADD_MESSAGE',['outofrange','%s의 글자 수를 맞추어 주세요.']);
v.cast('ADD_MESSAGE',['equalto','%s이(가) 잘못되었습니다.']);
v.cast('ADD_MESSAGE',['invalid','%s의 값이 올바르지 않습니다.']);
v.cast('ADD_MESSAGE',['invalid_email','%s의 값은 올바른 메일 주소가 아닙니다.']);
v.cast('ADD_MESSAGE',['invalid_userid','%s의 값은 영문, 숫자, _만 가능하며 첫 글자는 영문이어야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_user_id','%s의 값은 영문, 숫자, _만 가능하며 첫 글자는 영문이어야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_homepage','%s의 형식이 잘못되었습니다.(예: https://www.rhymix.org/)']);
v.cast('ADD_MESSAGE',['invalid_url','%s의 형식이 잘못되었습니다.(예: https://www.rhymix.org/)']);
v.cast('ADD_MESSAGE',['invalid_korean','%s의 형식이 잘못되었습니다. 한글로만 입력해야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_korean_number','%s의 형식이 잘못되었습니다. 한글과 숫자로만 입력해야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_alpha','%s의 형식이 잘못되었습니다. 영문으로만 입력해야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_alpha_number','%s의 형식이 잘못되었습니다. 영문과 숫자로만 입력해야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_mid','%s의 형식이 잘못되었습니다. 첫 글자는 영문으로 시작해야 하며 \'영문+숫자+_\'로만 입력해야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_number','%s의 형식이 잘못되었습니다. 숫자로만 입력해야 합니다.']);
v.cast('ADD_MESSAGE',['invalid_extension','%s의 형식이 잘못되었습니다. *.* 나 *.jpg;*.gif; 처럼 입력해야 합니다.']);
})(jQuery);