You are here

function SelectTest::testIsNotNullCondition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/SelectTest.php \Drupal\system\Tests\Database\SelectTest::testIsNotNullCondition()

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

File

core/modules/system/src/Tests/Database/SelectTest.php, line 244
Contains \Drupal\system\Tests\Database\SelectTest.

Class

SelectTest
Tests the Select query builder.

Namespace

Drupal\system\Tests\Database

Code

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