mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 20:53:53 +01:00
enhanced int comparison test
This commit is contained in:
parent
5ce534eb7c
commit
e5d1410b23
@ -3019,16 +3019,15 @@ class dml_test extends UnitTestCase {
|
||||
|
||||
$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->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null, null);
|
||||
$table->add_field('content', XMLDB_TYPE_TEXT, 'big', XMLDB_UNSIGNED, XMLDB_NOTNULL);
|
||||
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
|
||||
$dbman->create_table($table);
|
||||
|
||||
$DB->insert_record($tablename, array('course' => 3, 'content' => 'hello'));
|
||||
$DB->insert_record($tablename, array('course' => 3, 'content' => 'world'));
|
||||
$DB->insert_record($tablename, array('course' => 5, 'content' => 'hello'));
|
||||
$DB->insert_record($tablename, array('course' => 2, 'content' => 'universe'));
|
||||
$DB->insert_record($tablename, array('course' => 7, 'content' => '1'));
|
||||
$DB->insert_record($tablename, array('course' => 7, 'content' => '2'));
|
||||
$DB->insert_record($tablename, array('course' => 3, 'content' => 'hello', 'name'=>'xyz'));
|
||||
$DB->insert_record($tablename, array('course' => 3, 'content' => 'world', 'name'=>'abc'));
|
||||
$DB->insert_record($tablename, array('course' => 5, 'content' => 'hello', 'name'=>'def'));
|
||||
$DB->insert_record($tablename, array('course' => 2, 'content' => 'universe', 'name'=>'abc'));
|
||||
|
||||
// we have sql like this in moodle, this syntax breaks on older versions of sqlite for example..
|
||||
$sql = "SELECT a.id AS id, a.course AS course
|
||||
@ -3048,10 +3047,15 @@ class dml_test extends UnitTestCase {
|
||||
// test int x string comparison
|
||||
$sql = "SELECT *
|
||||
FROM {{$tablename}} c
|
||||
WHERE content = ?";
|
||||
$records1 = $DB->get_records_sql($sql, array(1));
|
||||
$records2 = $DB->get_records_sql($sql, array("1"));
|
||||
$this->assertEqual(count($records1), count($records2));
|
||||
WHERE name = ?";
|
||||
$this->assertEqual(count($DB->get_records_sql($sql, array(10))), 0);
|
||||
$this->assertEqual(count($DB->get_records_sql($sql, array("10"))), 0);
|
||||
$DB->insert_record($tablename, array('course' => 7, 'content' => 'xx', 'name'=>'1'));
|
||||
$DB->insert_record($tablename, array('course' => 7, 'content' => 'yy', 'name'=>'2'));
|
||||
$this->assertEqual(count($DB->get_records_sql($sql, array(1))), 1);
|
||||
$this->assertEqual(count($DB->get_records_sql($sql, array("1"))), 1);
|
||||
$this->assertEqual(count($DB->get_records_sql($sql, array(10))), 0);
|
||||
$this->assertEqual(count($DB->get_records_sql($sql, array("10"))), 0);
|
||||
}
|
||||
|
||||
function test_onelevel_commit() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user