function RegressionTest::testDBFieldExists

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

Tests the \Drupal\Core\Database\Schema::fieldExists() method.

File

core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php, line 48

Class

RegressionTest
Regression tests cases for the database layer.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testDBFieldExists() {
    $schema = $this->connection
        ->schema();
    $this->assertSame(TRUE, $schema->fieldExists('test', 'name'), 'Returns true for existent column.');
    $this->assertSame(FALSE, $schema->fieldExists('test', 'nosuchcolumn'), 'Returns false for nonexistent column.');
}

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