You are here

function ThemeInstallerTest::testThemeInfoAlter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Extension/ThemeInstallerTest.php \Drupal\system\Tests\Extension\ThemeInstallerTest::testThemeInfoAlter()

Tests that theme info can be altered by a module.

See also

module_test_system_info_alter()

File

core/modules/system/src/Tests/Extension/ThemeInstallerTest.php, line 310
Contains \Drupal\system\Tests\Extension\ThemeInstallerTest.

Class

ThemeInstallerTest
Tests installing and uninstalling of themes.

Namespace

Drupal\system\Tests\Extension

Code

function testThemeInfoAlter() {
  $name = 'seven';
  $this->container
    ->get('state')
    ->set('module_test.hook_system_info_alter', TRUE);
  $this
    ->themeInstaller()
    ->install(array(
    $name,
  ));
  $themes = $this
    ->themeHandler()
    ->listInfo();
  $this
    ->assertFalse(isset($themes[$name]->info['regions']['test_region']));

  // Rebuild module data so we know where module_test is located.
  // @todo Remove as part of https://www.drupal.org/node/2186491
  system_rebuild_module_data();
  $this
    ->moduleInstaller()
    ->install(array(
    'module_test',
  ), FALSE);
  $this
    ->assertTrue($this
    ->moduleHandler()
    ->moduleExists('module_test'));
  $themes = $this
    ->themeHandler()
    ->listInfo();
  $this
    ->assertTrue(isset($themes[$name]->info['regions']['test_region']));

  // Legacy assertions.
  // @todo Remove once theme initialization/info has been modernized.
  // @see https://www.drupal.org/node/2228093
  $info = system_get_info('theme', $name);
  $this
    ->assertTrue(isset($info['regions']['test_region']));
  $regions = system_region_list($name);
  $this
    ->assertTrue(isset($regions['test_region']));
  $system_list = system_list('theme');
  $this
    ->assertTrue(isset($system_list[$name]->info['regions']['test_region']));
  $this
    ->moduleInstaller()
    ->uninstall(array(
    'module_test',
  ));
  $this
    ->assertFalse($this
    ->moduleHandler()
    ->moduleExists('module_test'));
  $themes = $this
    ->themeHandler()
    ->listInfo();
  $this
    ->assertFalse(isset($themes[$name]->info['regions']['test_region']));

  // Legacy assertions.
  // @todo Remove once theme initialization/info has been modernized.
  // @see https://www.drupal.org/node/2228093
  $info = system_get_info('theme', $name);
  $this
    ->assertFalse(isset($info['regions']['test_region']));
  $regions = system_region_list($name);
  $this
    ->assertFalse(isset($regions['test_region']));
  $system_list = system_list('theme');
  $this
    ->assertFalse(isset($system_list[$name]->info['regions']['test_region']));
}