You are here

public function SelectTest::testNullCondition in Drupal 8

Same name and namespace in other branches
  1. 9 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.');
}