You are here

public function ThemeHandlerTest::testRebuildThemeData in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php \Drupal\Tests\Core\Extension\ThemeHandlerTest::testRebuildThemeData()

Tests rebuilding the theme data.

See also

\Drupal\Core\Extension\ThemeHandler::rebuildThemeData()

File

core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php, line 97
Contains \Drupal\Tests\Core\Extension\ThemeHandlerTest.

Class

ThemeHandlerTest
@coversDefaultClass \Drupal\Core\Extension\ThemeHandler @group Extension

Namespace

Drupal\Tests\Core\Extension

Code

public function testRebuildThemeData() {
  $this->extensionDiscovery
    ->expects($this
    ->at(0))
    ->method('scan')
    ->with('theme')
    ->will($this
    ->returnValue(array(
    'seven' => new Extension($this->root, 'theme', $this->root . '/core/themes/seven/seven.info.yml', 'seven.theme'),
  )));
  $this->extensionDiscovery
    ->expects($this
    ->at(1))
    ->method('scan')
    ->with('theme_engine')
    ->will($this
    ->returnValue(array(
    'twig' => new Extension($this->root, 'theme_engine', $this->root . '/core/themes/engines/twig/twig.info.yml', 'twig.engine'),
  )));
  $this->infoParser
    ->expects($this
    ->once())
    ->method('parse')
    ->with($this->root . '/core/themes/seven/seven.info.yml')
    ->will($this
    ->returnCallback(function ($file) {
    $info_parser = new InfoParser();
    return $info_parser
      ->parse($file);
  }));
  $this->moduleHandler
    ->expects($this
    ->once())
    ->method('buildModuleDependencies')
    ->will($this
    ->returnArgument(0));
  $this->moduleHandler
    ->expects($this
    ->once())
    ->method('alter');
  $theme_data = $this->themeHandler
    ->rebuildThemeData();
  $this
    ->assertCount(1, $theme_data);
  $info = $theme_data['seven'];

  // Ensure some basic properties.
  $this
    ->assertInstanceOf('Drupal\\Core\\Extension\\Extension', $info);
  $this
    ->assertEquals('seven', $info
    ->getName());
  $this
    ->assertEquals($this->root . '/core/themes/seven/seven.info.yml', $info
    ->getPathname());
  $this
    ->assertEquals($this->root . '/core/themes/seven/seven.theme', $info
    ->getExtensionPathname());
  $this
    ->assertEquals($this->root . '/core/themes/engines/twig/twig.engine', $info->owner);
  $this
    ->assertEquals('twig', $info->prefix);
  $this
    ->assertEquals('twig', $info->info['engine']);
  $this
    ->assertEquals(array(
    'seven/global-styling',
  ), $info->info['libraries']);
}