function SelectTest::testIsNullCondition

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testIsNullCondition()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/SelectTest.php \Drupal\KernelTests\Core\Database\SelectTest::testIsNullCondition()
  3. 11.x 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 228

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->assertEqual($names[0], 'Fozzie', 'Correct record returned for NULL age.');
}

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