From 531bf2648919624bee62335efc67964be8c65362 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 28 Sep 2006 22:11:06 +0000 Subject: [PATCH] Adding two more tests (create and drop foreign keys) --- admin/xmldb/actions/test/test.class.php | 33 +++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/admin/xmldb/actions/test/test.class.php b/admin/xmldb/actions/test/test.class.php index 6a7e8cf37f..2e385da6ca 100644 --- a/admin/xmldb/actions/test/test.class.php +++ b/admin/xmldb/actions/test/test.class.php @@ -473,7 +473,7 @@ class test extends XMLDBAction { $tests['add unique key'] = $test; } - /// 30th test. Adding one foreign key to the table + /// 30th test. Adding one foreign+unique key to the table if ($test->status) { /// Get SQL code and execute it $test = new stdClass; @@ -493,7 +493,7 @@ class test extends XMLDBAction { /// Get SQL code and execute it $test = new stdClass; $key = new XMLDBKey('course'); - $key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'course', array('id')); + $key->setAttributes(XMLDB_KEY_FOREIGN_UNIQUE, array('course'), 'anothertest', array('id')); $test->sql = $table->getDropKeySQL($CFG->dbtype, $CFG->prefix, $key, true); $test->status = drop_key($table, $key, false, false); @@ -503,6 +503,35 @@ class test extends XMLDBAction { $tests['drop foreign+unique key'] = $test; } + /// 32th test. Adding one foreign key to the table + if ($test->status) { + /// Get SQL code and execute it + $test = new stdClass; + $key = new XMLDBKey('course'); + $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id')); + + $test->sql = $table->getAddKeySQL($CFG->dbtype, $CFG->prefix, $key, true); + $test->status = add_key($table, $key, false, false); + if (!$test->status) { + $test->error = $db->ErrorMsg(); + } + $tests['add foreign key'] = $test; + } + + /// 33th test. Drop one foreign key + if ($test->status) { + /// Get SQL code and execute it + $test = new stdClass; + $key = new XMLDBKey('course'); + $key->setAttributes(XMLDB_KEY_FOREIGN, array('course'), 'anothertest', array('id')); + + $test->sql = $table->getDropKeySQL($CFG->dbtype, $CFG->prefix, $key, true); + $test->status = drop_key($table, $key, false, false); + if (!$test->status) { + $test->error = $db->ErrorMsg(); + } + $tests['drop foreign key'] = $test; + } /// TODO: Check here values of the inserted records to see that everything ha the correct value -- 2.39.5