dblayeroo : update tests

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4628 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2018-10-24 14:35:00 +00:00
parent b87bb3840d
commit 3e6c8714dc

View File

@@ -46,6 +46,7 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
"with space"=>array ("varchar(255)"))); "with space"=>array ("varchar(255)")));
$tbl1->unique (array ()); $tbl1->unique (array ());
$tbl1->primary ("group"); $tbl1->primary ("group");
$tbl1->realTypes (array ("group" => "regex(/^\S{1,10}$/)"));
return $tbl1; return $tbl1;
} }
@@ -1082,4 +1083,249 @@ class test_dblayeroo_{ENGINE} extends PHPUnit_Framework_TestCase
8 => 'usersoo', 8 => 'usersoo',
), $res); ), $res);
} }
//// CHECK REAL TYPES TESTS ////
public function test_checkRealType_integerPositive_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_integerPositive",
"1", "");
$this->assertSame (null, $res);
}
public function test_checkRealType_integerPositive_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_integerPositive",
"-1", "");
$this->assertSame ("Invalid positive integer : ".
"can not start by minus sign", $res);
}
public function test_checkRealType_integerPositive_3 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_integerPositive",
"0777", "");
$this->assertSame ("Invalid positive integer : ".
"can not start by Zero", $res);
}
public function test_checkRealType_integerPositive_4 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_integerPositive",
"07a7", "");
$this->assertSame ("Invalid positive integer : ".
"invalid char", $res);
}
public function test_checkRealType_allowedchars_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_allowedchars",
"1111", "allowedchars(123)");
$this->assertSame (null, $res);
}
public function test_checkRealType_allowedchars_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_allowedchars",
"-1", "allowedchars(123)");
$this->assertSame ("Invalid char provided", $res);
}
public function test_checkRealType_array_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_array",
"235", "array('123','235','256')");
$this->assertSame (null, $res);
}
public function test_checkRealType_array_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_array",
"777", "array('123','235','256')");
$this->assertSame ("Invalid value provided : not in allowed list", $res);
}
public function test_checkRealType_regex_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_regex",
"235", "regex(/^\\d+$/)");
$this->assertSame (null, $res);
}
public function test_checkRealType_regex_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_regex",
"235", "regex(/^\\d{3}$/)");
$this->assertSame (null, $res);
}
public function test_checkRealType_regex_3 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_regex",
"235", "regex(/^\\d{4}$/)");
$this->assertSame ("Invalid value provided : do not match the regex", $res);
}
public function test_checkRealType_regex_4 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_regex",
"abcdef", "regex(/^[a-z]+$/)");
$this->assertSame (null, $res);
}
public function test_checkRealType_regex_5 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_regex",
"Abcdef", "regex(/^[a-z]+$/)");
$this->assertSame ("Invalid value provided : do not match the regex", $res);
}
public function test_checkRealType_mail_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_mail",
"toto@example.com", "");
$this->assertSame (null, $res);
}
public function test_checkRealType_mail_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_mail",
"toto@", "");
$this->assertSame ("Invalid mail provided", $res);
}
public function test_checkRealType_uuid_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_uuid",
"4e799e3f-f376-46e5-a5db-85200949987e", "");
$this->assertSame (null, $res);
}
public function test_checkRealType_uuid_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_uuid",
"4E799E3F-F376-46E5-A5DB-85200949987E", "");
$this->assertSame (null, $res);
}
public function test_checkRealType_uuid_3 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_uuid",
"4E799E3F-F376-46E5+A5DB+85200949987E", "");
$this->assertSame ("Invalid UUID provided : invalid char", $res);
}
public function test_checkRealType_uuid_4 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_uuid",
"4E799E3F5F376546E55A5DB585200949987E", "");
$this->assertSame ("Invalid UUID provided : missing dash", $res);
}
public function test_checkRealType_sqldate_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqldate",
"2018-10-24", "");
$this->assertSame (null, $res);
}
public function test_checkRealType_sqldate_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqldate",
"2018/10/24", "");
$this->assertSame ("Invalid date provided : invalid chars", $res);
}
public function test_checkRealType_sqldate_3 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqldate",
"2018-10-32", "");
$this->assertSame ("Invalid date provided : can not parse the date", $res);
}
public function test_checkRealType_sqltime_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqltime",
"12:34:56", "");
$this->assertSame (null, $res);
}
public function test_checkRealType_sqltime_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqltime",
"12;22;22", "");
$this->assertSame ("Invalid time provided : invalid chars", $res);
}
public function test_checkRealType_sqltime_3 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqltime",
"32:34:56", "");
$this->assertSame ("Invalid time provided : can not parse the time", $res);
}
public function test_checkRealType_sqldatetime_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqldatetime",
"2018-10-24 22:23:24", "");
$this->assertSame (null, $res);
}
public function test_checkRealType_sqldatetime_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqldatetime",
"2018/10/24", "");
$this->assertSame ("Invalid date and time provided : invalid length", $res);
}
public function test_checkRealType_sqldatetime_3 ()
{
$tbl1 = $this->tbl1 ();
$res = $this->invokeMethod ($tbl1, "checkRealType_sqldatetime",
"2018-10-24 25:12:25", "");
$this->assertSame ("Invalid date and time provided : ".
"can not parse the date", $res);
}
//// TEST REAL TYPES ////
public function test_checkRealType_1 ()
{
$tbl1 = $this->tbl1 ();
$res = $tbl1->checkRealType (array ("group" => "notempty"));
$this->assertSame (array (
"object" => "The field can not be empty",
"where" => "The field can not be empty",
), $res);
}
public function test_checkRealType_2 ()
{
$tbl1 = $this->tbl1 ();
$res = $tbl1->checkRealType (array ("group" => "not valid"));
$this->assertSame (array (
"group" => "Invalid value provided : do not match the regex",
"object" => "The field can not be empty",
"where" => "The field can not be empty",
), $res);
}
public function test_checkRealType_3 ()
{
$tbl1 = $this->tbl1 ();
$res = $tbl1->checkRealType (array ("group" => "notempty"), true);
$this->assertSame (array (), $res);
}
public function test_checkRealType_4 ()
{
$tbl1 = $this->tbl1 ();
$res = $tbl1->checkRealType (array ("group" => "not valid"), true);
$this->assertSame (array (
"group" => "Invalid value provided : do not match the regex",
), $res);
}
} }