You are here

public function RegressionTest::testDBFieldExists in Drupal 8

Same name and namespace in other branches
  1. 9 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.');
}