block_rebuild example

parent::setUpBeforeClass();

    // @todo Once block_rebuild() is refactored to auto-loadable code, remove     // this require statement.     require_once static::getDrupalRoot() . '/core/modules/block/block.module';
  }

  /** * @covers ::block_rebuild */
  public function testRebuildNoBlocks() {
    block_rebuild();
    $messages = \Drupal::messenger()->all();
    \Drupal::messenger()->deleteAll();
    $this->assertEquals([]$messages);
  }

  /** * @covers ::block_rebuild */
  public function testRebuildNoInvalidBlocks() {
    $this->placeBlock('system_powered_by_block', ['region' => 'content']);

    
$this->executeMigrations([
      'language',
      'd7_filter_format',
      'block_content_type',
      'block_content_body_field',
      'd7_custom_block',
      'd7_user_role',
      'd7_block',
      'd7_block_translation',
    ]);
    block_rebuild();
  }

  /** * Tests the migration of block title translation. */
  public function testBlockContentTranslation() {
    /** @var \Drupal\language\ConfigurableLanguageManagerInterface $language_manager */
    $language_manager = $this->container->get('language_manager');

    $config = $language_manager->getLanguageConfigOverride('fr', 'block.block.bartik_user_login');
    $this->assertSame('fr - User login title', $config->get('settings.label'));
  }
$config->set('admin', 'claro');
    $config->save();

    $this->executeMigrations([
      'd7_filter_format',
      'd7_user_role',
      'block_content_type',
      'block_content_body_field',
      'd7_custom_block',
      'd7_block',
    ]);
    block_rebuild();
  }

  /** * Asserts various aspects of a block. * * @param string $id * The block ID. * @param string $plugin_id * The block's plugin ID. * @param array $roles * Role IDs the block is expected to have. * @param string $pages * The list of pages on which the block should appear. * @param string $region * The display region. * @param string $theme * The theme. * @param int $weight * The block weight. * @param string $label * The block label. * @param string $label_display * The block label display setting. * @param bool $status * Whether the block is expected to be enabled or disabled. * * @internal */
$this->executeMigrations([
      'language',
      'd6_filter_format',
      'block_content_type',
      'block_content_body_field',
      'd6_custom_block',
      'd6_user_role',
      'd6_block',
      'd6_block_translation',
    ]);
    block_rebuild();
  }

  /** * Tests the migration of block title translation. */
  public function testBlockContentTranslation() {
    /** @var \Drupal\language\ConfigurableLanguageManagerInterface $language_manager */
    $language_manager = $this->container->get('language_manager');

    $config = $language_manager->getLanguageConfigOverride('zu', 'block.block.user_1');
    $this->assertSame('zu - Navigation', $config->get('settings.label'));
  }
$config->set('default', 'olivero');
    $config->save();

    $this->executeMigrations([
      'd6_filter_format',
      'block_content_type',
      'block_content_body_field',
      'd6_custom_block',
      'd6_user_role',
      'd6_block',
    ]);
    block_rebuild();
  }

  /** * Asserts various aspects of a block. * * @param string $id * The block ID. * @param array $visibility * The block visibility settings. * @param string $region * The display region. * @param string $theme * The theme. * @param int $weight * The block weight. * @param array $settings * (optional) The block settings. * @param bool $status * Whether the block is expected to be enabled or disabled. * * @internal */
Home | Imprint | This part of the site doesn't use cookies.