mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-22 05:15:29 +09:00
Bug fix for Argument class - added global $lang in validation methods.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8725 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
f64e950463
commit
da8302fa4a
2 changed files with 67 additions and 31 deletions
|
|
@ -97,6 +97,7 @@
|
||||||
|
|
||||||
function checkFilter($filter_type){
|
function checkFilter($filter_type){
|
||||||
if(isset($this->value) && $this->value != ''){
|
if(isset($this->value) && $this->value != ''){
|
||||||
|
global $lang;
|
||||||
$val = $this->value;
|
$val = $this->value;
|
||||||
$key = $this->name;
|
$key = $this->name;
|
||||||
switch($filter_type) {
|
switch($filter_type) {
|
||||||
|
|
@ -146,25 +147,28 @@
|
||||||
|
|
||||||
function checkMaxLength($length){
|
function checkMaxLength($length){
|
||||||
if($this->value && (strlen($this->value) > $length)){
|
if($this->value && (strlen($this->value) > $length)){
|
||||||
|
global $lang;
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
$key = $this->name;
|
$key = $this->name;
|
||||||
$this->errorMessage = new Object(-1, $lang->filter->outofrange, $lang->{$key} ? $lang->{$key} : $key);
|
$this->errorMessage = new Object(-1, sprintf($lang->filter->outofrange, $lang->{$key} ? $lang->{$key} : $key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkMinLength($length){
|
function checkMinLength($length){
|
||||||
if($this->value && (strlen($this->value) > $length)){
|
if($this->value && (strlen($this->value) < $length)){
|
||||||
|
global $lang;
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
$key = $this->name;
|
$key = $this->name;
|
||||||
$this->errorMessage = new Object(-1, $lang->filter->outofrange, $lang->{$key} ? $lang->{$key} : $key);
|
$this->errorMessage = new Object(-1, sprintf($lang->filter->outofrange, $lang->{$key} ? $lang->{$key} : $key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkNotNull(){
|
function checkNotNull(){
|
||||||
if(!isset($this->value)){
|
if(!isset($this->value)){
|
||||||
|
global $lang;
|
||||||
$this->isValid = false;
|
$this->isValid = false;
|
||||||
$key = $this->name;
|
$key = $this->name;
|
||||||
$this->errorMessage = new Object(-1, $lang->filter->isnull, $lang->{$key} ? $lang->{$key} : $key);
|
$this->errorMessage = new Object(-1, sprintf($lang->filter->isnull, $lang->{$key} ? $lang->{$key} : $key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,38 @@
|
||||||
*/
|
*/
|
||||||
class ArgumentTest extends CubridTest {
|
class ArgumentTest extends CubridTest {
|
||||||
|
|
||||||
|
public function testErrorMessageIsSent_NotNullCheck(){
|
||||||
|
global $lang;
|
||||||
|
include(_XE_PATH_.'common/lang/en.lang.php');
|
||||||
|
|
||||||
|
$page_argument = new Argument('page', $args->page);
|
||||||
|
$page_argument->checkNotNull();
|
||||||
|
$this->assertFalse($page_argument->isValid());
|
||||||
|
$this->assertEquals("Please input a value for page", $page_argument->getErrorMessage()->message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testErrorMessageIsSent_MinLengthCheck(){
|
||||||
|
global $lang;
|
||||||
|
include(_XE_PATH_.'common/lang/en.lang.php');
|
||||||
|
|
||||||
|
$args->page = '123';
|
||||||
|
$page_argument = new Argument('page', $args->page);
|
||||||
|
$page_argument->checkMinLength(6);
|
||||||
|
$this->assertFalse($page_argument->isValid());
|
||||||
|
$this->assertEquals("Please align the text length of page", $page_argument->getErrorMessage()->message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testErrorMessageIsSent_MaxLengthCheck(){
|
||||||
|
global $lang;
|
||||||
|
include(_XE_PATH_.'common/lang/en.lang.php');
|
||||||
|
|
||||||
|
$args->page = '123';
|
||||||
|
$page_argument = new Argument('page', $args->page);
|
||||||
|
$page_argument->checkMaxLength(2);
|
||||||
|
$this->assertFalse($page_argument->isValid());
|
||||||
|
$this->assertEquals("Please align the text length of page", $page_argument->getErrorMessage()->message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Implement testGetType().
|
* @todo Implement testGetType().
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue