function ThemeTest::testFrontPageThemeSuggestion

Ensure page-front template suggestion is added when on front page.

File

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

Class

ThemeTest
Tests low-level theme functions.

Namespace

Drupal\system\Tests\Theme

Code

function testFrontPageThemeSuggestion() {
  $original_path = _current_path();

  // Set the current path to node because theme_get_suggestions() will query
  // it to see if we are on the front page.
  config('system.site')
    ->set('page.front', 'node')
    ->save();
  _current_path('node');
  $suggestions = theme_get_suggestions(array(
    'node',
  ), 'page');

  // Set it back to not annoy the batch runner.
  _current_path($original_path);
  $this
    ->assertTrue(in_array('page__front', $suggestions), 'Front page template was suggested.');
}