Dep: update

주로 PHAN
This commit is contained in:
2021-08-06 22:39:09 +09:00
parent 5310c2e7f6
commit b306601c72
1098 changed files with 92137 additions and 33228 deletions
+48 -24
View File
@@ -23,15 +23,17 @@ class BasicTest extends SimpleTest {
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`signature` VARCHAR( 255 ) NULL DEFAULT 'donewriting'
) ENGINE = InnoDB");
$mysqli = DB::get();
DB::disconnect();
@$this->assert($mysqli->server_info === null);
DB::query("CREATE TABLE `fake%s_table` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 255 ) NULL DEFAULT 'blah'
) ENGINE = InnoDB");
}
function test_1_5_empty_table() {
$counter = DB::queryFirstField("SELECT COUNT(*) FROM accounts");
$this->assert($counter === strval(0));
$this->assert(DB::lastQuery() === 'SELECT COUNT(*) FROM accounts');
$row = DB::queryFirstRow("SELECT * FROM accounts");
$this->assert($row === null);
@@ -95,16 +97,6 @@ class BasicTest extends SimpleTest {
$password = DB::queryFirstField("SELECT password FROM accounts WHERE favorite_word IS NULL");
$this->assert($password === 'goodbye');
DB::$usenull = false;
DB::insertUpdate('accounts', array(
'id' => 3,
'favorite_word' => null,
));
$password = DB::queryFirstField("SELECT password FROM accounts WHERE favorite_word=%s AND favorite_word=%s", null, '');
$this->assert($password === 'goodbye');
DB::$usenull = true;
DB::insertUpdate('accounts', array(
'id' => 3,
'favorite_word' => null,
@@ -156,19 +148,27 @@ class BasicTest extends SimpleTest {
$results = DB::query("SELECT * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert(count($results) === 3);
$columnlist = DB::columnList('accounts');
$this->assert(count($columnlist) === 8);
$this->assert($columnlist[0] === 'id');
$this->assert($columnlist[5] === 'height');
$columnList = DB::columnList('accounts');
$columnKeys = array_keys($columnList);
$this->assert(count($columnList) === 8);
$this->assert($columnList['id']['type'] == 'int(11)');
$this->assert($columnList['height']['type'] == 'double');
$this->assert($columnKeys[5] == 'height');
$tablelist = DB::tableList();
$this->assert(count($tablelist) === 2);
$this->assert(count($tablelist) === 3);
$this->assert($tablelist[0] === 'accounts');
$tablelist = null;
$tablelist = DB::tableList(DB::$dbName);
$this->assert(count($tablelist) === 2);
$this->assert(count($tablelist) === 3);
$this->assert($tablelist[0] === 'accounts');
$date = DB::queryFirstField("SELECT DATE_FORMAT(birthday, '%%m/%%d/%%Y') FROM accounts WHERE username=%s", "Charlie's Friend");
$this->assert($date === '09/10/2000');
$date = DB::queryFirstField("SELECT DATE_FORMAT('2009-10-04 22:23:00', '%m/%d/%Y')");;
$this->assert($date === '10/04/2009');
}
function test_4_1_query() {
@@ -186,7 +186,7 @@ class BasicTest extends SimpleTest {
$true = DB::update('accounts', array(
'password' => DB::sqleval("REPEAT('blah', %i)", 4),
'favorite_word' => null,
), 'username=%s', 'newguy');
), 'username=%s_name', array('name' => 'newguy'));
$row = null;
$row = DB::queryOneRow("SELECT * FROM accounts WHERE username=%s", 'newguy');
@@ -200,6 +200,11 @@ class BasicTest extends SimpleTest {
$this->assert(count($row) === 1);
$this->assert($row[0]['username'] === 'newguy');
$this->assert($row[0]['age'] === '172');
$row = DB::query("SELECT * FROM accounts WHERE password IN %li AND password IN %li0 AND username=%s", array('blahblahblahblah'), 'newguy');
$this->assert(count($row) === 1);
$this->assert($row[0]['username'] === 'newguy');
$this->assert($row[0]['age'] === '172');
$true = DB::query("DELETE FROM accounts WHERE password=%s", 'blahblahblahblah');
$this->assert($true === true);
@@ -214,7 +219,7 @@ class BasicTest extends SimpleTest {
'height' => 199.194
));
$ct = DB::queryFirstField("SELECT COUNT(*) FROM accounts WHERE username=%s AND height=%d", 'gonesoon', 199.194);
$ct = DB::queryFirstField("SELECT COUNT(*) FROM accounts WHERE %ha", array('username' => 'gonesoon', 'height' => 199.194));
$this->assert(intval($ct) === 1);
$ct = DB::queryFirstField("SELECT COUNT(*) FROM accounts WHERE username=%s1 AND height=%d0 AND height=%d", 199.194, 'gonesoon');
@@ -273,10 +278,10 @@ class BasicTest extends SimpleTest {
$columns = DB::columnList('store data');
$this->assert(count($columns) === 2);
$this->assert($columns[1] === 'picture');
$this->assert($columns['picture']['type'] === 'blob');
$smile = file_get_contents('smile1.jpg');
$smile = file_get_contents(__DIR__ . '/smile1.jpg');
DB::insert('store data', array(
'picture' => $smile,
));
@@ -409,7 +414,26 @@ class BasicTest extends SimpleTest {
DB::update('profile',array('signature'=> "%li "),"id = %d",1);
$signature = DB::queryFirstField("SELECT signature FROM profile WHERE id=%i", 1);
$this->assert($signature === "%li ");
}
function test_902_faketable() {
DB::insert('fake%s_table', array('name' => 'karen'));
$count = DB::queryFirstField("SELECT COUNT(*) FROM %b", 'fake%s_table');
$this->assert($count === '1');
DB::update('fake%s_table', array('name' => 'haren%s'), 'name=%s_name', array('name' => 'karen'));
DB::delete('fake%s_table', 'name=%s0', 'haren%s');
$count = DB::queryFirstField("SELECT COUNT(*) FROM %b", 'fake%s_table');
$this->assert($count === '0');
}
function test_10_parse() {
$parsed_query = DB::parse("SELECT * FROM %b WHERE id=%i AND name=%s", 'accounts', 5, 'Joe');
$correct_query = "SELECT * FROM `accounts` WHERE id=5 AND name='Joe'";
$this->assert($parsed_query === $correct_query);
$parsed_query = DB::parse("SELECT DATE_FORMAT(birthday, '%%Y-%%M-%%d %%h:%%i:%%s') AS mydate FROM accounts WHERE id=%i", 5);
$correct_query = "SELECT DATE_FORMAT(birthday, '%Y-%M-%d %h:%i:%s') AS mydate FROM accounts WHERE id=5";
$this->assert($parsed_query === $correct_query);
}
+16 -16
View File
@@ -1,17 +1,17 @@
<?php
class CallTest extends SimpleTest {
function test_1_create_procedure() {
DB::query("DROP PROCEDURE IF EXISTS myProc");
DB::query("CREATE PROCEDURE myProc()
BEGIN
SELECT * FROM accounts;
END");
}
function test_2_run_procedure() {
$r = DB::query("CALL myProc()");
$this->assert($r[0]['username'] === 'Abe');
$this->assert($r[2]['age'] === '914');
}
<?php
class CallTest extends SimpleTest {
function test_1_create_procedure() {
DB::query("DROP PROCEDURE IF EXISTS myProc");
DB::query("CREATE PROCEDURE myProc()
BEGIN
SELECT * FROM accounts;
END");
}
function test_2_run_procedure() {
$r = DB::query("CALL myProc()");
$this->assert($r[0]['username'] === 'Abe');
$this->assert($r[2]['age'] === '914');
}
}
-83
View File
@@ -1,83 +0,0 @@
<?php
function new_error_callback($params) {
global $error_callback_worked;
if (substr_count($params['error'], 'You have an error in your SQL syntax')) $error_callback_worked = 1;
}
function my_debug_handler($params) {
global $debug_callback_worked;
if (substr_count($params['query'], 'SELECT')) $debug_callback_worked = 1;
}
class ErrorTest extends SimpleTest {
function test_1_error_handler() {
global $error_callback_worked, $static_error_callback_worked, $nonstatic_error_callback_worked;
DB::$error_handler = 'new_error_callback';
DB::query("SELET * FROM accounts");
$this->assert($error_callback_worked === 1);
DB::$error_handler = array('ErrorTest', 'static_error_callback');
DB::query("SELET * FROM accounts");
$this->assert($static_error_callback_worked === 1);
DB::$error_handler = array($this, 'nonstatic_error_callback');
DB::query("SELET * FROM accounts");
$this->assert($nonstatic_error_callback_worked === 1);
}
public static function static_error_callback($params) {
global $static_error_callback_worked;
if (substr_count($params['error'], 'You have an error in your SQL syntax')) $static_error_callback_worked = 1;
}
public function nonstatic_error_callback($params) {
global $nonstatic_error_callback_worked;
if (substr_count($params['error'], 'You have an error in your SQL syntax')) $nonstatic_error_callback_worked = 1;
}
function test_2_exception_catch() {
$dbname = DB::$dbName;
DB::$error_handler = '';
DB::$throw_exception_on_error = true;
try {
DB::query("SELET * FROM accounts");
} catch(MeekroDBException $e) {
$this->assert(substr_count($e->getMessage(), 'You have an error in your SQL syntax'));
$this->assert($e->getQuery() === 'SELET * FROM accounts');
$exception_was_caught = 1;
}
$this->assert($exception_was_caught === 1);
try {
DB::insert("`$dbname`.`accounts`", array(
'id' => 2,
'username' => 'Another Dude\'s \'Mom"',
'password' => 'asdfsdse',
'age' => 35,
'height' => 555.23
));
} catch(MeekroDBException $e) {
$this->assert(substr_count($e->getMessage(), 'Duplicate entry'));
$exception_was_caught = 2;
}
$this->assert($exception_was_caught === 2);
}
function test_3_debugmode_handler() {
global $debug_callback_worked;
DB::debugMode('my_debug_handler');
DB::query("SELECT * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert($debug_callback_worked === 1);
DB::debugMode(false);
}
}
?>
@@ -1,19 +0,0 @@
<?php
class ErrorTest_53 extends SimpleTest {
function test_1_error_handler() {
global $anonymous_error_callback_worked;
DB::$throw_exception_on_error = false;
DB::$error_handler = function($params) {
global $anonymous_error_callback_worked;
if (substr_count($params['error'], 'You have an error in your SQL syntax')) $anonymous_error_callback_worked = 1;
};
DB::query("SELET * FROM accounts");
$this->assert($anonymous_error_callback_worked === 1);
}
}
?>
-51
View File
@@ -1,51 +0,0 @@
<?php
class HelperTest extends SimpleTest {
function test_1_verticalslice() {
$all = DB::query("SELECT * FROM accounts ORDER BY id ASC");
$names = DBHelper::verticalSlice($all, 'username');
$this->assert(count($names) === 5);
$this->assert($names[0] === 'Abe');
$ages = DBHelper::verticalSlice($all, 'age', 'username');
$this->assert(count($ages) === 5);
$this->assert($ages['Abe'] === '700');
}
function test_2_reindex() {
$all = DB::query("SELECT * FROM accounts ORDER BY id ASC");
$names = DBHelper::reIndex($all, 'username');
$this->assert(count($names) === 5);
$this->assert($names['Bart']['username'] === 'Bart');
$this->assert($names['Bart']['age'] === '15');
$names = DBHelper::reIndex($all, 'username', 'age');
$this->assert($names['Bart']['15']['username'] === 'Bart');
$this->assert($names['Bart']['15']['age'] === '15');
}
function test_3_empty() {
$none = DB::query("SELECT * FROM accounts WHERE username=%s", 'doesnotexist');
$this->assert(is_array($none) && count($none) === 0);
$names = DBHelper::verticalSlice($none, 'username', 'age');
$this->assert(is_array($names) && count($names) === 0);
$names_other = DBHelper::reIndex($none, 'username', 'age');
$this->assert(is_array($names_other) && count($names_other) === 0);
}
function test_4_null() {
DB::query("UPDATE accounts SET password = NULL WHERE username=%s", 'Bart');
$all = DB::query("SELECT * FROM accounts ORDER BY id ASC");
$ages = DBHelper::verticalSlice($all, 'age', 'password');
$this->assert(count($ages) === 5);
$this->assert($ages[''] === '15');
$passwords = DBHelper::reIndex($all, 'password');
$this->assert(count($passwords) === 5);
$this->assert($passwords['']['username'] === 'Bart');
$this->assert($passwords['']['password'] === NULL);
}
}
?>
+287
View File
@@ -0,0 +1,287 @@
<?php
function my_error_handler($hash) {
global $error_callback_worked;
if (substr_count($hash['error'], 'You have an error in your SQL syntax')) $error_callback_worked = 1;
return false;
}
function my_success_handler($hash) {
global $debug_callback_worked;
if (substr_count($hash['query'], 'SELECT')) $debug_callback_worked = 1;
return false;
}
class HookTest extends SimpleTest {
static function static_error_callback($hash) {
global $static_error_callback_worked;
if (substr_count($hash['error'], 'You have an error in your SQL syntax')) $static_error_callback_worked = 1;
return false;
}
function nonstatic_error_callback($hash) {
global $nonstatic_error_callback_worked;
if (substr_count($hash['error'], 'You have an error in your SQL syntax')) $nonstatic_error_callback_worked = 1;
return false;
}
function test_1_error_handler() {
global $error_callback_worked, $static_error_callback_worked, $nonstatic_error_callback_worked;
DB::addHook('run_failed', 'my_error_handler');
DB::query("SELET * FROM accounts");
$this->assert($error_callback_worked === 1);
DB::removeHooks('run_failed');
DB::addHook('run_failed', array('HookTest', 'static_error_callback'));
DB::query("SELET * FROM accounts");
$this->assert($static_error_callback_worked === 1);
DB::removeHooks('run_failed');
DB::addHook('run_failed', array($this, 'nonstatic_error_callback'));
DB::query("SELET * FROM accounts");
$this->assert($nonstatic_error_callback_worked === 1);
DB::removeHooks('run_failed');
}
function test_2_exception_catch() {
$dbname = DB::$dbName;
try {
DB::query("SELET * FROM accounts");
} catch(MeekroDBException $e) {
$this->assert(substr_count($e->getMessage(), 'You have an error in your SQL syntax'));
$this->assert($e->getQuery() === 'SELET * FROM accounts');
$exception_was_caught = 1;
}
$this->assert($exception_was_caught === 1);
$this->assert(DB::lastQuery() === 'SELET * FROM accounts');
try {
DB::insert("`$dbname`.`accounts`", array(
'id' => 2,
'username' => 'Another Dude\'s \'Mom"',
'password' => 'asdfsdse',
'age' => 35,
'height' => 555.23
));
} catch(MeekroDBException $e) {
$this->assert(substr_count($e->getMessage(), 'Duplicate entry'));
$exception_was_caught = 2;
}
$this->assert($exception_was_caught === 2);
}
function test_3_success_handler() {
global $debug_callback_worked;
DB::addHook('run_success', 'my_success_handler');
DB::query("SELECT * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert($debug_callback_worked === 1);
DB::removeHooks('run_success');
}
function test_4_error_handler() {
global $anonymous_error_callback_worked;
$error_handler = function($hash) {
global $anonymous_error_callback_worked;
if (substr_count($hash['error'], 'You have an error in your SQL syntax')) {
$anonymous_error_callback_worked = 1;
}
return false;
};
DB::addHook('run_failed', $error_handler);
DB::query("SELET * FROM accounts");
$this->assert($anonymous_error_callback_worked === 1);
DB::removeHooks('run_failed');
}
function test_5_post_run_success() {
$callback_worked = false;
$fn = function($hash) use (&$callback_worked) {
if (!isset($hash['error']) && !isset($hash['exception'])) {
$callback_worked = true;
}
};
DB::addHook('post_run', $fn);
DB::query("SELECT * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert($callback_worked);
DB::removeHooks('post_run');
}
function test_6_post_run_failed() {
$callback_worked = false;
$fn = function($hash) use (&$callback_worked) {
if ($hash['error'] && $hash['exception']) {
$expected_query = "SELEC * FROM accounts WHERE username!='Charlie\'s Friend'";
$expected_error = "error in your SQL syntax";
if ($hash['exception']->getQuery() == $expected_query && substr_count($hash['error'], $expected_error)) {
$callback_worked = true;
}
}
};
DB::addHook('post_run', $fn);
DB::addHook('run_failed', function() { return false; }); // disable exception throwing
DB::query("SELEC * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert($callback_worked);
DB::removeHooks('post_run');
DB::removeHooks('run_failed');
}
function test_7_pre_run() {
$callback_worked = false;
$fn = function($args) { return str_replace('SLCT', 'SELET', $args['query']); };
$fn2 = function($args) { return str_replace('SELET', 'SELECT', $args['query']); };
$fn3 = function($args) use (&$callback_worked) { $callback_worked = true; };
DB::addHook('pre_run', $fn);
DB::addHook('pre_run', $fn2);
$last_hook = DB::addHook('pre_run', $fn3);
$results = DB::query("SLCT * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert(count($results) == 4);
$this->assert($callback_worked);
$callback_worked = false;
DB::removeHook('pre_run', $last_hook);
$results = DB::query("SLCT * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert(count($results) == 4);
$this->assert(!$callback_worked);
DB::removeHooks('pre_run');
}
function test_8_pre_parse() {
$callback_worked = false;
$fn = function($args) {
$args['query'] = str_replace('SLCT', 'SELECT', $args['query']);
return array($args['query'], $args['args']);
};
$fn2 = function($args) {
$args['args'][0] = '1ofmany';
return array($args['query'], $args['args']);
};
$fn3 = function() use (&$callback_worked) {
$callback_worked = true;
};
DB::addHook('pre_parse', $fn);
DB::addHook('pre_parse', $fn2);
DB::addHook('pre_parse', $fn3);
$row = DB::queryFirstRow("SLCT * FROM accounts WHERE username=%s", "asdf");
$this->assert($row['password'] == 'something');
$this->assert($callback_worked);
DB::removeHooks('pre_parse');
}
function test_9_enough_args() {
$error_worked = false;
try {
DB::query("SELECT * FROM accounts WHERE id=%i AND username=%s", 1);
} catch (MeekroDBException $e) {
if ($e->getMessage() == 'Expected 2 args, but only got 1!') {
$error_worked = true;
}
}
$this->assert($error_worked);
}
function test_10_named_keys_present() {
$error_worked = false;
try {
DB::query("SELECT * FROM accounts WHERE id=%i_id AND username=%s_username", array('username' => 'asdf'));
} catch (MeekroDBException $e) {
if ($e->getMessage() == "Couldn't find named arg id!") {
$error_worked = true;
}
}
$this->assert($error_worked);
}
function test_11_expect_array() {
$error_worked = false;
try {
DB::query("SELECT * FROM accounts WHERE id IN %li", 5);
} catch (MeekroDBException $e) {
if ($e->getMessage() == "Expected an array for arg 0 but didn't get one!") {
$error_worked = true;
}
}
$this->assert($error_worked);
}
function test_12_named_keys_without_array() {
$error_worked = false;
try {
DB::query("SELECT * FROM accounts WHERE id=%i_named", 1);
} catch (MeekroDBException $e) {
if ($e->getMessage() == "If you use named args, you must pass an assoc array of args!") {
$error_worked = true;
}
}
$this->assert($error_worked);
}
function test_13_mix_named_numbered_args() {
$error_worked = false;
try {
DB::query("SELECT * FROM accounts WHERE id=%i_named AND username=%s", array('named' => 1));
} catch (MeekroDBException $e) {
if ($e->getMessage() == "You can't mix named and numbered args!") {
$error_worked = true;
}
}
$this->assert($error_worked);
}
function test_14_arrays_not_empty() {
$error_worked = false;
try {
DB::query("SELECT * FROM accounts WHERE id IN %li", array());
} catch (MeekroDBException $e) {
if ($e->getMessage() == "Arg 0 array can't be empty!") {
$error_worked = true;
}
}
$this->assert($error_worked);
}
function test_15_named_array_not_empty() {
$error_worked = false;
try {
DB::query("SELECT * FROM accounts WHERE id IN %li_ids", array('ids' => array()));
} catch (MeekroDBException $e) {
if ($e->getMessage() == "Arg ids array can't be empty!") {
$error_worked = true;
}
}
$this->assert($error_worked);
}
}
?>
+7 -5
View File
@@ -117,10 +117,12 @@ class ObjectTest extends SimpleTest {
$results = $this->mdb->query("SELECT * FROM accounts WHERE username!=%s", "Charlie's Friend");
$this->assert(count($results) === 2);
$columnlist = $this->mdb->columnList('accounts');
$this->assert(count($columnlist) === 6);
$this->assert($columnlist[0] === 'id');
$this->assert($columnlist[4] === 'height');
$columnList = $this->mdb->columnList('accounts');
$columnKeys = array_keys($columnList);
$this->assert(count($columnList) === 6);
$this->assert($columnList['id']['type'] == 'int(11)');
$this->assert($columnList['height']['type'] == 'double');
$this->assert($columnKeys[4] == 'height');
$tablelist = $this->mdb->tableList();
$this->assert(count($tablelist) === 1);
@@ -215,7 +217,7 @@ class ObjectTest extends SimpleTest {
) ENGINE = InnoDB");
$smile = file_get_contents('smile1.jpg');
$smile = file_get_contents(__DIR__ . '/smile1.jpg');
$this->mdb->insert('storedata', array(
'picture' => $smile,
));
+48
View File
@@ -0,0 +1,48 @@
<?php
class WalkTest extends SimpleTest {
function test_1_walk() {
$Walk = DB::queryWalk("SELECT * FROM accounts");
$results = array();
while ($row = $Walk->next()) {
$results[] = $row;
}
$this->assert(count($results) == 8);
$this->assert($results[7]['username'] == 'vookoo');
}
function test_2_walk_empty() {
$Walk = DB::queryWalk("SELECT * FROM accounts WHERE id>100");
$results = array();
while ($row = $Walk->next()) {
$results[] = $row;
}
$this->assert(count($results) == 0);
}
function test_3_walk_insert() {
$Walk = DB::queryWalk("INSERT INTO profile (id) VALUES (100)");
$results = array();
while ($row = $Walk->next()) {
$results[] = $row;
}
$this->assert(count($results) == 0);
DB::query("DELETE FROM profile WHERE id=100");
}
function test_4_walk_incomplete() {
$Walk = DB::queryWalk("SELECT * FROM accounts");
$Walk->next();
unset($Walk);
// if $Walk hasn't been properly freed, this will produce an out of sync error
DB::query("SELECT * FROM accounts");
}
}
@@ -5,7 +5,7 @@ class WhereClauseTest extends SimpleTest {
$where->add('username=%s', 'Bart');
$where->add('password=%s', 'hello');
$result = DB::query("SELECT * FROM accounts WHERE %l", $where->text());
$result = DB::query("SELECT * FROM accounts WHERE %l", $where);
$this->assert(count($result) === 1);
$this->assert($result[0]['age'] === '15');
}
@@ -17,7 +17,7 @@ class WhereClauseTest extends SimpleTest {
$subclause->add('age=%i', 15);
$subclause->add('age=%i', 14);
$result = DB::query("SELECT * FROM accounts WHERE %l", $where->text());
$result = DB::query("SELECT * FROM accounts WHERE %l", $where);
$this->assert(count($result) === 1);
$this->assert($result[0]['age'] === '15');
}
@@ -29,7 +29,7 @@ class WhereClauseTest extends SimpleTest {
$subclause->add('username!=%s', 'Bart');
$subclause->negateLast();
$result = DB::query("SELECT * FROM accounts WHERE %l", $where->text());
$result = DB::query("SELECT * FROM accounts WHERE %l", $where);
$this->assert(count($result) === 1);
$this->assert($result[0]['age'] === '15');
}
@@ -58,7 +58,17 @@ class WhereClauseTest extends SimpleTest {
$this->assert($result[0]['age'] === '15');
}
function test_6_or() {
function test_6_negate_two() {
$where = new WhereClause('and');
$where->add('password=%s', 'hello');
$where->add('username=%s', 'Bart');
$where->negate();
$result = DB::query("SELECT * FROM accounts WHERE %l", $where);
$this->assert(count($result) === 7);
}
function test_7_or() {
$where = new WhereClause('or');
$where->add('username=%s', 'Bart');
$where->add('username=%s', 'Abe');
+13 -24
View File
@@ -10,8 +10,6 @@ class SimpleTest {
debug_print_backtrace();
die;
}
}
function microtime_float()
@@ -20,48 +18,39 @@ function microtime_float()
return ((float)$usec + (float)$sec);
}
if (phpversion() >= '5.3') $is_php_53 = true;
else $is_php_53 = false;
ini_set('date.timezone', 'America/Los_Angeles');
error_reporting(E_ALL | E_STRICT);
require_once '../db.class.php';
include 'test_setup.php'; //test config values go here
require_once __DIR__ . '/../db.class.php';
require_once __DIR__ . '/test_setup.php'; //test config values go here
// WARNING: ALL tables in the database will be dropped before the tests, including non-test related tables.
DB::$user = $set_db_user;
DB::$password = $set_password;
DB::$dbName = $set_db;
DB::$host = $set_host;
DB::get(); //connect to mysql
require_once 'BasicTest.php';
require_once 'CallTest.php';
require_once 'ObjectTest.php';
require_once 'WhereClauseTest.php';
require_once 'ErrorTest.php';
require_once 'TransactionTest.php';
require_once 'HelperTest.php';
require_once __DIR__ . '/BasicTest.php';
require_once __DIR__ . '/WalkTest.php';
require_once __DIR__ . '/CallTest.php';
require_once __DIR__ . '/ObjectTest.php';
require_once __DIR__ . '/WhereClauseTest.php';
require_once __DIR__ . '/HookTest.php';
require_once __DIR__ . '/TransactionTest.php';
$classes_to_test = array(
'BasicTest',
'WalkTest',
'CallTest',
'WhereClauseTest',
'ObjectTest',
'ErrorTest',
'HookTest',
'TransactionTest',
'HelperTest',
);
if ($is_php_53) {
require_once 'ErrorTest_53.php';
$classes_to_test[] = 'ErrorTest_53';
} else {
echo "PHP 5.3 not detected, skipping 5.3 tests..\n";
}
$mysql_version = DB::serverVersion();
if ($mysql_version >= '5.5') {
require_once 'TransactionTest_55.php';
require_once __DIR__ . '/TransactionTest_55.php';
$classes_to_test[] = 'TransactionTest_55';
} else {
echo "MySQL 5.5 not available (version is $mysql_version) -- skipping MySQL 5.5 tests\n";