function DatabaseTestBase::ensureSampleDataNull

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

Sets up tables for NULL handling.

4 calls to DatabaseTestBase::ensureSampleDataNull()
SelectTest::testIsNotNullCondition in core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
Tests that we can find a record without a NULL value.
SelectTest::testIsNullCondition in core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
Tests that we can find a record with a NULL value.
SelectTest::testNullCondition in core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
Tests that a comparison with NULL is always FALSE.
UpdateTest::testSimpleNullUpdate in core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php
Confirms updating to NULL.

File

core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php, line 46

Class

DatabaseTestBase
Base class for databases database tests.

Namespace

Drupal\KernelTests\Core\Database

Code

public function ensureSampleDataNull() {
    $this->connection
        ->insert('test_null')
        ->fields([
        'name',
        'age',
    ])
        ->values([
        'name' => 'Kermit',
        'age' => 25,
    ])
        ->values([
        'name' => 'Ernie',
        'age' => NULL,
    ])
        ->values([
        'name' => 'Gonzo',
        'age' => 27,
    ])
        ->execute();
}

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