From: stronk7 Date: Sat, 29 Aug 2009 01:17:57 +0000 (+0000) Subject: Added some more tests to temp tables to show current implementation problems in mysql... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f906838a4ea904c444a10573bd67a0a23abc104a;p=moodle.git Added some more tests to temp tables to show current implementation problems in mysql and mssql. Fix coming soon. --- diff --git a/lib/ddl/simpletest/testddl.php b/lib/ddl/simpletest/testddl.php index e70340a8a6..d9cf9fd347 100755 --- a/lib/ddl/simpletest/testddl.php +++ b/lib/ddl/simpletest/testddl.php @@ -1247,7 +1247,8 @@ class ddl_test extends UnitTestCase { $this->assertTrue($dbman->table_exists('test_table1')); } - public function testCreateTempTable() { + public function test_temp_tables() { + $DB = $this->tdb; // do not use global $DB! $dbman = $this->tdb->get_manager(); $table = $this->tables['test_table1']; @@ -1256,12 +1257,27 @@ class ddl_test extends UnitTestCase { $dbman->create_temp_table($table); $this->assertTrue($dbman->table_exists('test_table1', true)); + // Get columns and perform some basic tests + $columns = $DB->get_columns('test_table1', false); + $this->assertEqual(count($columns), 10); + $this->assertTrue($columns['name'] instanceof database_column_info); + $this->assertEqual($columns['name']->max_length, 30); + $this->assertTrue($columns['name']->has_default); + $this->assertEqual($columns['name']->default_value, 'Moodle'); + + // Insert some records + $inserted = $this->fill_deftable('test_table1'); + $records = $DB->get_records('test_table1'); + $this->assertEqual(count($records), $inserted); + $this->assertEqual($records[1]->course, $this->records['test_table1'][0]->course); + $this->assertEqual($records[1]->secondname, $this->records['test_table1'][0]->secondname); + $this->assertEqual($records[2]->intro, $this->records['test_table1'][1]->intro); + // Delete $dbman->drop_temp_table($table); $this->assertFalse($dbman->table_exists('test_table1', true)); } - public function test_reset_sequence() { $DB = $this->tdb; $dbman = $DB->get_manager();