]> git.mjollnir.org Git - moodle.git/commitdiff
Moving some tests up and down and introducing some more
authorstronk7 <stronk7>
Thu, 28 Sep 2006 23:16:29 +0000 (23:16 +0000)
committerstronk7 <stronk7>
Thu, 28 Sep 2006 23:16:29 +0000 (23:16 +0000)
tests about changing column types. Not working yet unded mssql

admin/xmldb/actions/test/test.class.php

index 2e385da6ca0d4f89e01e0a7a8806a7af15a63002..17cecccff3c1170390ba1c6ddc7b68776771c619 100644 (file)
@@ -214,7 +214,73 @@ class test extends XMLDBAction {
             }
             $tests['drop field again'] = $test;
         }
-    /// 8th test. Change the precision of one text field
+
+    /// 8th test. Change the type of one column from integer to varchar
+        if ($test->status) {
+        /// Get SQL code and execute it
+            $test = new stdClass;
+            $field = new XMLDBField('course');
+            $field->setAttributes(XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL, null, null, null, '0');
+
+            $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
+            $test->status = change_field_type($table, $field, false, false);
+            if (!$test->status) {
+                $test->error = $db->ErrorMsg();
+            }
+            $tests['change field type (int2char)'] = $test;
+        }
+
+    /// 9th test. Change the type of one column from varchar to integer
+        if ($test->status) {
+        /// Get SQL code and execute it
+            $test = new stdClass;
+            $field = new XMLDBField('course');
+            $field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
+
+            $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
+            $test->status = change_field_type($table, $field, false, false);
+            if (!$test->status) {
+                $test->error = $db->ErrorMsg();
+            }
+            $tests['change field type (char2int)'] = $test;
+        }
+
+    /// 10th test. Change the type of one column from number to varchar
+        if ($test->status) {
+        /// Get SQL code and execute it
+            $test = new stdClass;
+            $field = new XMLDBField('grade');
+            $field->setAttributes(XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null, null, 'test');
+
+            $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
+            $test->status = change_field_type($table, $field, false, false);
+            if (!$test->status) {
+                $test->error = $db->ErrorMsg();
+            }
+            $tests['change field type (number2char)'] = $test;
+        }
+
+    /// 11th test. Change the type of one column from varchar to number
+        if ($test->status) {
+        /// Get SQL code and execute it
+            $test = new stdClass;
+            $field = new XMLDBField('grade');
+            $field->setAttributes(XMLDB_TYPE_NUMBER, '10,2', XMLDB_UNSIGNED, null, null, null, null, null);
+
+            $test->sql = $table->getAlterFieldSQL($CFG->dbtype, $CFG->prefix, $field, true);
+            $test->status = change_field_type($table, $field, false, false);
+            if (!$test->status) {
+                $test->error = $db->ErrorMsg();
+            }
+            $tests['change field type (char2number)'] = $test;
+        }
+
+    /// 12th test. Change the type of one column from text to binary
+
+    /// 13th test. Change the type of one column from binary to text
+
+
+    /// 14th test. Change the precision of one text field
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
@@ -229,7 +295,7 @@ class test extends XMLDBAction {
             $tests['change field precision (text)'] = $test;
         }
 
-    /// 9th test. Change the precision of one char field
+    /// 15th test. Change the precision of one char field
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
@@ -244,7 +310,7 @@ class test extends XMLDBAction {
             $tests['change field precision (char)'] = $test;
         }
 
-    /// 10th test. Change the precision of one numeric field
+    /// 16th test. Change the precision of one numeric field
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
@@ -259,20 +325,6 @@ class test extends XMLDBAction {
             $tests['change field precision (number)'] = $test;
         }
 
-    /// 11th test. Change the type of one column from varchar to integer
-
-    /// 12th test. Change the type of one column from insteger to varchar
-
-    /// 13th test. Change the type of one column from varchar to number
-
-    /// 14th test. Change the type of one column from number to varchar
-
-    /// 15th test. Change the type of one column from text to binary
-
-    /// 16th test. Change the type of one column from binary to text
-
-
-
     /// 17th test. Change the sign of one numeric field to unsigned
         if ($test->status) {
         /// Get SQL code and execute it