You are here

function ThemeTest::testListThemes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Theme/ThemeTest.php \Drupal\system\Tests\Theme\ThemeTest::testListThemes()

Test the listInfo() function.

File

core/modules/system/src/Tests/Theme/ThemeTest.php, line 213
Contains \Drupal\system\Tests\Theme\ThemeTest.

Class

ThemeTest
Tests low-level theme functions.

Namespace

Drupal\system\Tests\Theme

Code

function testListThemes() {
  $theme_handler = $this->container
    ->get('theme_handler');
  $theme_handler
    ->install(array(
    'test_subtheme',
  ));
  $themes = $theme_handler
    ->listInfo();

  // Check if ThemeHandlerInterface::listInfo() retrieves enabled themes.
  $this
    ->assertIdentical(1, $themes['test_theme']->status, 'Installed theme detected');

  // Check if ThemeHandlerInterface::listInfo() returns disabled themes.
  // Check for base theme and subtheme lists.
  $base_theme_list = array(
    'test_basetheme' => 'Theme test base theme',
  );
  $sub_theme_list = array(
    'test_subsubtheme' => 'Theme test subsubtheme',
    'test_subtheme' => 'Theme test subtheme',
  );
  $this
    ->assertIdentical($themes['test_basetheme']->sub_themes, $sub_theme_list, 'Base theme\'s object includes list of subthemes.');
  $this
    ->assertIdentical($themes['test_subtheme']->base_themes, $base_theme_list, 'Subtheme\'s object includes list of base themes.');

  // Check for theme engine in subtheme.
  $this
    ->assertIdentical($themes['test_subtheme']->engine, 'twig', 'Subtheme\'s object includes the theme engine.');

  // Check for theme engine prefix.
  $this
    ->assertIdentical($themes['test_basetheme']->prefix, 'twig', 'Base theme\'s object includes the theme engine prefix.');
  $this
    ->assertIdentical($themes['test_subtheme']->prefix, 'twig', 'Subtheme\'s object includes the theme engine prefix.');
}