Commit 41a802eb authored by Alexander Butenko's avatar Alexander Butenko

Improve tests

parent d0d29dd9
...@@ -10,7 +10,7 @@ $tables = Array ( ...@@ -10,7 +10,7 @@ $tables = Array (
'login' => 'char(10) not null', 'login' => 'char(10) not null',
'customerId' => 'int(10) not null', 'customerId' => 'int(10) not null',
'firstName' => 'char(10) not null', 'firstName' => 'char(10) not null',
'lastName' => 'char(10) not null', 'lastName' => 'char(10)',
'password' => 'text not null', 'password' => 'text not null',
'createdAt' => 'datetime', 'createdAt' => 'datetime',
'expires' => 'datetime', 'expires' => 'datetime',
...@@ -30,7 +30,7 @@ $data = Array ( ...@@ -30,7 +30,7 @@ $data = Array (
Array ('login' => 'user2', Array ('login' => 'user2',
'customerId' => 10, 'customerId' => 10,
'firstName' => 'Mike', 'firstName' => 'Mike',
'lastName' => 'B', 'lastName' => NULL,
'password' => $db->func('SHA1(?)',Array ("secretpassword2+salt")), 'password' => $db->func('SHA1(?)',Array ("secretpassword2+salt")),
'createdAt' => $db->now(), 'createdAt' => $db->now(),
'expires' => $db->now('+1Y'), 'expires' => $db->now('+1Y'),
...@@ -92,7 +92,6 @@ if ($db->count != 1) { ...@@ -92,7 +92,6 @@ if ($db->count != 1) {
echo $db->getLastQuery(); echo $db->getLastQuery();
exit; exit;
} }
// FIXME ADD IN and BETWEEN CHECKS
$db->groupBy("customerId"); $db->groupBy("customerId");
$cnt = $db->get ("users", null, "customerId, count(id) as cnt"); $cnt = $db->get ("users", null, "customerId, count(id) as cnt");
...@@ -109,11 +108,44 @@ $db->where ("id", 1); ...@@ -109,11 +108,44 @@ $db->where ("id", 1);
$cnt = $db->update("users", $upData); $cnt = $db->update("users", $upData);
$db->where ("id", 1); $db->where ("id", 1);
$db->getOne("users"); $r = $db->getOne("users");
if ($db->count != 1) { if ($db->count != 1) {
echo "Invalid users count on getOne()"; echo "Invalid users count on getOne()";
exit; exit;
} }
if ($r['password'] != '546f98b24edfdc3b9bbe0d241bd8b29783f71b32') {
echo "Invalid password were set".
exit;
}
$db->where ("id", Array('in' => Array('1','2','3')));
$db->get("users");
if ($db->count != 3) {
echo "Invalid users count on where() with in ";
exit;
}
$db->where ("id", Array('between' => Array('2','3')));
$db->get("users");
if ($db->count != 2) {
echo "Invalid users count on where() with between";
exit;
}
$db->where ("id", 2);
$db->orWhere ("customerId", 11);
$r = $db->get("users");
if ($db->count != 2) {
echo "Invalid users count on orWhere()";
exit;
}
$db->where ("lastName", Array("<=>" => NULL));
$r = $db->get("users");
if ($db->count != 1) {
echo "Invalid users count on null where()";
exit;
}
$db->delete("users"); $db->delete("users");
$db->get("users"); $db->get("users");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment