summaryrefslogtreecommitdiffstats
path: root/application/controllers/tools.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-02-05 21:49:12 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-02-05 21:49:12 +0100
commitd3726c7c0e497def97efcf610fdcac9bbebb0f3e (patch)
treebed39120b332f763c65aa5fd63abec3941ce7bf9 /application/controllers/tools.php
parentdb8a70bbcb941fde96a0ac98919702c49814d0c5 (diff)
Add simple testsuite
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/controllers/tools.php')
-rw-r--r--application/controllers/tools.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/application/controllers/tools.php b/application/controllers/tools.php
index 8c0785409..f04f86224 100644
--- a/application/controllers/tools.php
+++ b/application/controllers/tools.php
@@ -42,4 +42,41 @@ class Tools extends MY_Controller {
throw new \exceptions\ApiException("tools/update_database/migration-error", $this->migration->error_string());
}
}
+
+ function drop_all_tables_using_prefix()
+ {
+ $tables = $this->db->list_tables();
+ $prefix = $this->db->dbprefix;
+ $tables_to_drop = array();
+
+ foreach ($tables as $table) {
+ if (strpos($table, $prefix) === 0) {
+ $tables_to_drop[] = $this->db->protect_identifiers($table);
+ }
+ }
+
+ $this->db->query('SET FOREIGN_KEY_CHECKS = 0');
+ $this->db->query('DROP TABLE '.implode(", ", $tables_to_drop));
+ $this->db->query('SET FOREIGN_KEY_CHECKS = 1');
+ }
+
+ function test()
+ {
+ global $argv;
+ $url = $argv[3];
+ $testcase = $argv[4];
+
+ $testclass = '\tests\\'.$testcase;
+ $test = new $testclass();
+ $test->setServer($url);
+
+ $refl = new ReflectionClass($test);
+ foreach ($refl->getMethods() as $method) {
+ if (strpos($method->name, "test_") === 0) {
+ $test->init();
+ $test->{$method->name}();
+ $test->cleanup();
+ }
+ }
+ }
}