<?php
-# Copyright (C) 2009 Jason Woofenden
+# Copyright (C) 2010 Jason Woofenden
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
require_once('code/wfpl/db.php');
-# returns number of errors
-function test_db_reposition() {
- $table = 'reposition';
- $errors = 0;
+function test_db_reposition($table = 'reposition') {
db_delete($table);
db_insert($table, 'ord', '2');
$a = db_auto_id();
db_update($table, 'ord', $ord, 'where id=%i', $before[$src]);
$after = db_get_column($table, 'id', 'order by ord');
$ords = db_get_column($table, 'ord', 'order by ord');
- if($before[$c1] != $after[0] || $before[$c2] != $after[1] || $before[$c3] != $after[2]) {
- message("db_reposition($before[$src], $dest) did: ($before[0]:$before_ords[0], $before[1]:$before_ords[1], $before[2]:$before_ords[2]) -> ($after[0]:$ords[0]), $after[1]:$ords[1], $after[2]:$ords[2])");
- $errors += 1;
+ $message = "db_reposition($before[$src], $dest) did: ($before[0]:$before_ords[0], $before[1]:$before_ords[1], $before[2]:$before_ords[2]) -> ($after[0]:$ords[0]), $after[1]:$ords[1], $after[2]:$ords[2])";
+ if($before[$c1] == $after[0] && $before[$c2] == $after[1] && $before[$c3] == $after[2]) {
+ unit_test_passed($message);
+ } else {
+ unit_test_failed($message);
}
$before = $after;
$before_ords = $ords;
}
-
- return $errors;
}
-# returns number of errors
function db_unit_tests_main() {
db_connect('test');
- $errors = 0;
- $errors += test_db_reposition();
- return $errors;
+ test_db_reposition();
}