MDL-63020 tests: ensure that searching for is null values also works ok
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 24 Sep 2018 15:38:10 +0000 (17:38 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 24 Sep 2018 15:38:10 +0000 (17:38 +0200)
lib/dml/tests/dml_test.php

index ad8380c..fb144e9 100644 (file)
@@ -2445,23 +2445,27 @@ class core_dml_testcase extends database_driver_testcase {
 
         $this->assertEquals(2, $DB->count_records($table->getName()));
         $this->assertEquals(1, $DB->count_records($table->getName(), ['nullable1' => 1]));
+        $this->assertEquals(1, $DB->count_records($table->getName(), ['nullable1' => null]));
 
         // And it should be possible to insert a duplicate.
         $DB->insert_record($tablename, (object) ['notnull1' => 1, 'nullable1' => null, 'nullable2' => null]);
 
         $this->assertEquals(3, $DB->count_records($table->getName()));
         $this->assertEquals(1, $DB->count_records($table->getName(), ['nullable1' => 1]));
+        $this->assertEquals(2, $DB->count_records($table->getName(), ['nullable1' => null]));
 
         // Same, but with only one of the nullable columns being null.
         $DB->insert_record($tablename, (object) ['notnull1' => 1, 'nullable1' => 1, 'nullable2' => null]);
 
         $this->assertEquals(4, $DB->count_records($table->getName()));
         $this->assertEquals(2, $DB->count_records($table->getName(), ['nullable1' => 1]));
+        $this->assertEquals(2, $DB->count_records($table->getName(), ['nullable1' => null]));
 
         $DB->insert_record($tablename, (object) ['notnull1' => 1, 'nullable1' => 1, 'nullable2' => null]);
 
         $this->assertEquals(5, $DB->count_records($table->getName()));
         $this->assertEquals(3, $DB->count_records($table->getName(), ['nullable1' => 1]));
+        $this->assertEquals(2, $DB->count_records($table->getName(), ['nullable1' => null]));
 
     }