class BlockRemoveSyndicateBlocksUpdateTest

Tests removing blocks placed using the removed Syndicate block plugin.

Attributes

#[Group('Update')] #[Group('block')] #[CoversFunction('block_post_update_remove_syndicate_blocks')] #[RunTestsInSeparateProcesses]

Hierarchy

Expanded class hierarchy of BlockRemoveSyndicateBlocksUpdateTest

See also

block_post_update_remove_syndicate_blocks()

File

core/modules/block/tests/src/Functional/Update/BlockRemoveSyndicateBlocksUpdateTest.php, line 17

Namespace

Drupal\Tests\block\Functional\Update
View source
class BlockRemoveSyndicateBlocksUpdateTest extends UpdatePathTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() : void {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../../../system/tests/fixtures/update/drupal-11.3.0.bare.standard.php.gz',
      __DIR__ . '/../../../fixtures/update/syndicate-block-config.php',
    ];
  }
  
  /**
   * Tests that node module Syndicate blocks are deleted in all themes.
   */
  public function testRemoveSyndicateBlocks() : void {
    $config_factory = $this->container
      ->get('config.factory');
    $syndicate_blocks = [
      'block.block.olivero_syndicate',
      'block.block.stark_syndicate',
    ];
    foreach ($syndicate_blocks as $name) {
      $this->assertSame('node_syndicate_block', $config_factory->get($name)
        ->get('plugin'));
    }
    $this->assertSame('custom_syndicate', $config_factory->get('block.block.stark_custom_syndicate')
      ->get('settings.provider'));
    $this->assertFalse($config_factory->get('block.block.stark_powered')
      ->isNew());
    $this->runUpdates();
    $config_factory = $this->container
      ->get('config.factory');
    foreach ($syndicate_blocks as $name) {
      $this->assertTrue($config_factory->get($name)
        ->isNew(), "{$name} was deleted.");
    }
    // A block using the same plugin ID from another provider is kept, which
    // allows a contrib module to take over the block before the update.
    $this->assertFalse($config_factory->get('block.block.stark_custom_syndicate')
      ->isNew());
    // Other blocks are not affected.
    $this->assertFalse($config_factory->get('block.block.stark_powered')
      ->isNew());
  }

}

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