Skip to content
Browse files

MDL-19057 more create_table tests for broken structure of table

  • Loading branch information...
1 parent ebdf7f7 commit 7e67b7b79edf5bf6ba548e693cd37ed92ed21b9f @skodak skodak committed
Showing with 33 additions and 0 deletions.
  1. +33 −0 lib/ddl/simpletest/testddl.php
View
33 lib/ddl/simpletest/testddl.php
@@ -275,6 +275,39 @@ public function test_create_table() {
$this->assertEqual($dbrec->name, 'Moodle');
$this->assertEqual($dbrec->thirdname, '');
+ // check exceptions if multiple R columns
+ $table = new xmldb_table ('test_table2');
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('rid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, array('rid'));
+ $table->setComment("This is a test'n drop table. You can drop it safely");
+
+ $this->tables[$table->getName()] = $table;
+
+ try {
+ $dbman->create_table($table);
+ $this->fail('Exception expected');
+ } catch (Exception $e) {
+ $this->assertTrue($e instanceof ddl_exception);
+ }
+
+ // check exceptions missing primary key on R column
+ $table = new xmldb_table ('test_table2');
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0');
+ $table->setComment("This is a test'n drop table. You can drop it safely");
+
+ $this->tables[$table->getName()] = $table;
+
+ try {
+ $dbman->create_table($table);
+ $this->fail('Exception expected');
+ } catch (Exception $e) {
+ $this->assertTrue($e instanceof ddl_exception);
+ }
+
}
/**

0 comments on commit 7e67b7b

Please sign in to comment.
Something went wrong with that request. Please try again.