From aa8503fdd092c448f7cb2ea17bd159ba424caef6 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sat, 30 Sep 2006 17:06:59 +0000 Subject: [PATCH] Added 3 more tests to check change_field_enum() --- admin/xmldb/actions/test/test.class.php | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/admin/xmldb/actions/test/test.class.php b/admin/xmldb/actions/test/test.class.php index fbb210aa89..9de98e9750 100644 --- a/admin/xmldb/actions/test/test.class.php +++ b/admin/xmldb/actions/test/test.class.php @@ -614,6 +614,55 @@ class test extends XMLDBAction { } $tests['drop foreign key'] = $test; } + + /// 34th test. Adding one complex enum field + if ($test->status) { + /// Create a new field with complex specs (enums are good candidates) + $field = new XMLDBField('type'); + $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course'); + /// Get SQL code and execute it + $test = new stdClass; + $test->sql = $table->getAddFieldSQL($CFG->dbtype, $CFG->prefix, $field, true); + $test->status = add_field($table, $field, false, false); + if (!$test->status) { + $test->error = $db->ErrorMsg(); + } + $tests['add field with enum'] = $test; + } + + /// 35th test. Dropping the enum of one field + if ($test->status) { + /// Get SQL code and execute it + $test = new stdClass; + $field = new XMLDBField('type'); + $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'general', 'course'); + + $test->sql = $table->getModifyEnumSQL($CFG->dbtype, $CFG->prefix, $field, true); + $test->status = change_field_enum($table, $field, false, false); + if (!$test->status) { + $test->error = $db->ErrorMsg(); + } + $tests['delete enumlist from one field'] = $test; + } + + /// 36th test. Creating the default for one field + if ($test->status) { + /// Get SQL code and execute it + $test = new stdClass; + $field = new XMLDBField('type'); + $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, XMLDB_ENUM, array('single', 'news', 'general', 'social', 'eachuser', 'teacher', 'qanda'), 'general', 'course'); + + $test->sql = $table->getModifyEnumSQL($CFG->dbtype, $CFG->prefix, $field, true); + $test->status = change_field_enum($table, $field, false, false); + if (!$test->status) { + $test->error = $db->ErrorMsg(); + } + $tests['add enumlist to one field'] = $test; + } + + + + /// TODO: Check here values of the inserted records to see that everything ha the correct value -- 2.39.5