function SelectTest::testNullCondition

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testNullCondition()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testNullCondition()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testNullCondition()

Tests that a comparison with NULL is always FALSE.

File

core/tests/Drupal/KernelTests/Core/Database/SelectTest.php, line 214

Class

SelectTest
Tests the Select query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testNullCondition() {
    $this->ensureSampleDataNull();
    $names = $this->connection
        ->select('test_null', 'tn')
        ->fields('tn', [
        'name',
    ])
        ->condition('age', NULL)
        ->execute()
        ->fetchCol();
    $this->assertCount(0, $names, 'No records found when comparing to NULL.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.