You are here

public function SelectTest::testIsNullCondition in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testIsNullCondition()

Tests that we can find a record with a NULL value.

File

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

Class

SelectTest
Tests the Select query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testIsNullCondition() {
  $this
    ->ensureSampleDataNull();
  $names = $this->connection
    ->select('test_null', 'tn')
    ->fields('tn', [
    'name',
  ])
    ->isNull('age')
    ->execute()
    ->fetchCol();
  $this
    ->assertCount(1, $names, 'Correct number of records found with NULL age.');
  $this
    ->assertEquals('Fozzie', $names[0], 'Correct record returned for NULL age.');
}