Skip to content

Commit

Permalink
MDL-19057 more create_table tests for broken structure of table
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 13, 2010
1 parent ebdf7f7 commit 7e67b7b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions lib/ddl/simpletest/testddl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

/**
Expand Down

0 comments on commit 7e67b7b

Please sign in to comment.