]> git.mjollnir.org Git - moodle.git/commitdiff
Added to more tests to check float <---> char conversion
authorstronk7 <stronk7>
Fri, 29 Sep 2006 23:10:31 +0000 (23:10 +0000)
committerstronk7 <stronk7>
Fri, 29 Sep 2006 23:10:31 +0000 (23:10 +0000)
admin/xmldb/actions/test/test.class.php

index 26e64b45ff46c2e66d66d2be66e47d0d380c4409..d6f97f607af823f9f02265f1de30c2ba20178674 100644 (file)
@@ -260,24 +260,50 @@ class test extends XMLDBAction {
             $tests['change field type (number2char)'] = $test;
         }
 
-    /// 11th test. Change the type of one column from varchar to number
+    /// 11th test. Change the type of one column from varchar to float
         if ($test->status) {
         /// Get SQL code and execute it
             $test = new stdClass;
             $field = new XMLDBField('grade');
-            $field->setAttributes(XMLDB_TYPE_NUMBER, '20,10', XMLDB_UNSIGNED, null, null, null, null, null);
+            $field->setAttributes(XMLDB_TYPE_FLOAT, '20,10', 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;
+            $tests['change field type (char2float)'] = $test;
         }
 
-    /// 12th test. Change the type of one column from text to binary
+    /// 12th test. Change the type of one column from float to char
+        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 (float2char)'] = $test;
+        }
 
-    /// 13th test. Change the type of one column from binary to text
+    /// 13th test. Change the type of one column from char to number
+        if ($test->status) {
+        /// Get SQL code and execute it
+            $test = new stdClass;
+            $field = new XMLDBField('grade');
+            $field->setAttributes(XMLDB_TYPE_NUMBER, '20,10', 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;
+        }
 
 
     /// 14th test. Change the precision of one text field