function BlockConfigSyncTest::testNoBlocksCreatedDuringConfigSync

Tests blocks are not created during config sync.

@testWith [true, null] [false, "claro_test_block"]

Parameters

bool $syncing: Whether or not config is syncing when the hook is invoked.

string|null $expected_block_id: The expected ID of the block that should be created, or NULL if no block should be created.

File

core/modules/block/tests/src/Kernel/BlockConfigSyncTest.php, line 73

Class

BlockConfigSyncTest
Tests that blocks are not created during config sync.

Namespace

Drupal\Tests\block\Kernel

Code

public function testNoBlocksCreatedDuringConfigSync(bool $syncing, ?string $expected_block_id) : void {
    \Drupal::service(ConfigInstallerInterface::class)->setSyncing($syncing);
    // Invoke the hook that should skip block creation due to config sync.
    \Drupal::moduleHandler()->invoke('block', 'themes_installed', [
        [
            'claro',
        ],
    ]);
    // This should hold true if the "current" install profile triggers an
    // invocation of hook_modules_installed().
    \Drupal::moduleHandler()->invoke('block', 'modules_installed', [
        [
            'testing',
        ],
        $syncing,
    ]);
    $this->assertSame($expected_block_id, Block::load('claro_test_block')?->id());
}

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