You are here

public function SelectTest::testIsNotNullCondition 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::testIsNotNullCondition()

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

File

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

Class

SelectTest
Tests the Select query builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testIsNotNullCondition() {
  $this
    ->ensureSampleDataNull();
  $names = $this->connection
    ->select('test_null', 'tn')
    ->fields('tn', [
    'name',
  ])
    ->isNotNull('tn.age')
    ->orderBy('name')
    ->execute()
    ->fetchCol();
  $this
    ->assertCount(2, $names, 'Correct number of records found withNOT NULL age.');
  $this
    ->assertEquals('Gonzo', $names[0], 'Correct record returned for NOT NULL age.');
  $this
    ->assertEquals('Kermit', $names[1], 'Correct record returned for NOT NULL age.');
}