function NonPublicSchemaTest::testField

Same name in other branches
  1. 10 core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php \Drupal\Tests\pgsql\Kernel\pgsql\NonPublicSchemaTest::testField()

@covers ::addField @covers ::fieldExists @covers ::dropField @covers ::changeField

File

core/modules/pgsql/tests/src/Kernel/pgsql/NonPublicSchemaTest.php, line 130

Class

NonPublicSchemaTest
Tests schema API for non-public schema for the PostgreSQL driver.

Namespace

Drupal\Tests\pgsql\Kernel\pgsql

Code

public function testField() : void {
    $this->testingFakeConnection
        ->schema()
        ->addField('faking_table', 'added_field', [
        'type' => 'int',
        'not null' => FALSE,
    ]);
    $this->assertTrue($this->testingFakeConnection
        ->schema()
        ->fieldExists('faking_table', 'added_field'));
    $this->testingFakeConnection
        ->schema()
        ->changeField('faking_table', 'added_field', 'changed_field', [
        'type' => 'int',
        'not null' => FALSE,
    ]);
    $this->assertFalse($this->testingFakeConnection
        ->schema()
        ->fieldExists('faking_table', 'added_field'));
    $this->assertTrue($this->testingFakeConnection
        ->schema()
        ->fieldExists('faking_table', 'changed_field'));
    $this->testingFakeConnection
        ->schema()
        ->dropField('faking_table', 'changed_field');
    $this->assertFalse($this->testingFakeConnection
        ->schema()
        ->fieldExists('faking_table', 'changed_field'));
}

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