function ThemeTestTwig::testFindThemeTemplates

Tests drupal_find_theme_templates

File

drupal/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php, line 49
Definition of Drupal\system\Tests\Theme\ThemeTest.

Class

ThemeTestTwig
Tests low-level theme functions.

Namespace

Drupal\system\Tests\Theme

Code

function testFindThemeTemplates() {
  $cache = array();

  // Prime the theme cache
  foreach (module_implements('theme') as $module) {
    _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
  }

  // Check for correct content
  // @todo Remove this tests once double engine code is removed
  $this
    ->assertEqual($cache['node']['template_file'], 'core/modules/node/templates/node.twig', 'Node is using node.twig as template file');
  $this
    ->assertEqual($cache['node']['engine'], 'twig', 'Node is using twig engine');
  $this
    ->assertEqual($cache['theme_test_template_test']['template_file'], 'core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php', 'theme_test is using theme_test.template_test.tpl.php as template file');
  $this
    ->assertEqual($cache['theme_test_template_test']['engine'], 'phptemplate', 'theme_test is using phptemplate as engine.');
  $templates = drupal_find_theme_templates($cache, '.twig', drupal_get_path('theme', 'test_theme_twig'));
  $this
    ->assertEqual($templates['node__1']['template'], 'node--1', 'Template node--1.twig was found in test_theme_twig.');
}