function BlockContentTranslationUITest::testDisabledBundle

Test that no metadata is stored for a disabled bundle.

File

core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php, line 162

Class

BlockContentTranslationUITest
Tests the block content translation UI.

Namespace

Drupal\Tests\block_content\Functional

Code

public function testDisabledBundle() {
    // Create a bundle that does not have translation enabled.
    $disabled_bundle = $this->randomMachineName();
    $bundle = BlockContentType::create([
        'id' => $disabled_bundle,
        'label' => $disabled_bundle,
        'revision' => FALSE,
    ]);
    $bundle->save();
    // Create a block content for each bundle.
    $enabled_block_content = $this->createBlockContent();
    $disabled_block_content = $this->createBlockContent(FALSE, $bundle->id());
    // Make sure that only a single row was inserted into the block table.
    $rows = Database::getConnection()->query('SELECT * FROM {block_content_field_data} WHERE id = :id', [
        ':id' => $enabled_block_content->id(),
    ])
        ->fetchAll();
    $this->assertCount(1, $rows);
}

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