Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-29567 unit tests - add some tests to cover negative defaults in n…

…umerical cols
  • Loading branch information...
commit 13e183dd849debbf90e84d7e663384b9021c45c5 1 parent b558672
@stronk7 stronk7 authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/dml/simpletest/testdml.php
View
16 lib/dml/simpletest/testdml.php
@@ -649,6 +649,9 @@ public function test_get_columns() {
$table->add_field('onenum', XMLDB_TYPE_NUMBER, '10,2', null, null, null, 200);
$table->add_field('onefloat', XMLDB_TYPE_FLOAT, '10,2', null, null, null, 300);
$table->add_field('anotherfloat', XMLDB_TYPE_FLOAT, null, null, null, null, 400);
+ $table->add_field('negativedfltint', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '-1');
+ $table->add_field('negativedfltnumber', XMLDB_TYPE_NUMBER, '10', null, XMLDB_NOTNULL, null, '-2');
+ $table->add_field('negativedfltfloat', XMLDB_TYPE_FLOAT, '10', null, XMLDB_NOTNULL, null, '-3');
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$dbman->create_table($table);
@@ -713,6 +716,19 @@ public function test_get_columns() {
$this->assertEqual(400.0, $field->default_value);
$this->assertFalse($field->not_null);
+ // Test negative defaults in numerical columns
+ $field = $columns['negativedfltint'];
+ $this->assertTrue($field->has_default);
+ $this->assertEqual(-1, $field->default_value);
+
+ $field = $columns['negativedfltnumber'];
+ $this->assertTrue($field->has_default);
+ $this->assertEqual(-2, $field->default_value);
+
+ $field = $columns['negativedfltfloat'];
+ $this->assertTrue($field->has_default);
+ $this->assertEqual(-3, $field->default_value);
+
for ($i = 0; $i < count($columns); $i++) {
if ($i == 0) {
$next_column = reset($columns);
Please sign in to comment.
Something went wrong with that request. Please try again.