Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
@ -0,0 +1,15 @@
|
|||
# Themes are not supposed to provide/install this kind of config normally.
|
||||
# This exists for testing purposes only.
|
||||
# @see \Drupal\system\Tests\Extension\ThemeInstallerTest
|
||||
id: fancy
|
||||
label: 'Fancy date'
|
||||
status: true
|
||||
langcode: en
|
||||
locked: false
|
||||
pattern: 'U'
|
||||
dependencies:
|
||||
theme:
|
||||
- test_basetheme
|
||||
enforced:
|
||||
theme:
|
||||
- test_basetheme
|
|
@ -0,0 +1,4 @@
|
|||
features:
|
||||
favicon: false
|
||||
base: only
|
||||
override: base
|
|
@ -0,0 +1,10 @@
|
|||
test_basetheme.settings:
|
||||
type: theme_settings
|
||||
label: 'Test base theme settings'
|
||||
mapping:
|
||||
base:
|
||||
type: string
|
||||
label: 'Base theme setting'
|
||||
override:
|
||||
type: string
|
||||
label: 'Whether the setting has been overridden'
|
|
@ -0,0 +1,9 @@
|
|||
name: 'Theme test base theme'
|
||||
type: theme
|
||||
description: 'Test theme which acts as a base theme for other test subthemes.'
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
libraries:
|
||||
- test_basetheme/global-styling
|
||||
stylesheets-remove:
|
||||
- '@theme_test/css/base-remove.css'
|
|
@ -0,0 +1,7 @@
|
|||
global-styling:
|
||||
version: VERSION
|
||||
css:
|
||||
base:
|
||||
base-add.css: {}
|
||||
base-add.sub-remove.css: {}
|
||||
samename.css: {}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Add hooks for tests to use.
|
||||
*/
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
/**
|
||||
* Implements hook_views_pre_render().
|
||||
*/
|
||||
function test_basetheme_views_pre_render(ViewExecutable $view) {
|
||||
// We append the function name to the title for test to check for.
|
||||
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_post_render().
|
||||
*/
|
||||
function test_basetheme_views_post_render(ViewExecutable $view) {
|
||||
// We append the function name to the title for test to check for.
|
||||
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for theme_test_template_test templates.
|
||||
*/
|
||||
function test_basetheme_preprocess_theme_test_template_test(&$variables) {
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Theme test with invalid base theme'
|
||||
type: theme
|
||||
description: 'Test theme which has a non-existent base theme.'
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
base theme: not_real_test_basetheme
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Theme test with invalid theme engine'
|
||||
type: theme
|
||||
description: 'Test theme which has a non-existent theme engine.'
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
engine: not_real_engine
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Theme test subsubtheme'
|
||||
type: theme
|
||||
description: 'Test theme which uses test_subtheme as the base theme.'
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
base theme: test_subtheme
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Add hooks for tests to use.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for theme_test_template_test templates.
|
||||
*/
|
||||
function test_subsubtheme_preprocess_theme_test_template_test(&$variables) {
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
override: sub
|
|
@ -0,0 +1,7 @@
|
|||
test_subtheme.settings:
|
||||
type: theme_settings
|
||||
label: 'Test sub theme settings'
|
||||
mapping:
|
||||
override:
|
||||
type: string
|
||||
label: 'Whether the setting has been overridden'
|
|
@ -0,0 +1,11 @@
|
|||
name: 'Theme test subtheme'
|
||||
type: theme
|
||||
description: 'Test theme which uses test_basetheme as the base theme.'
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
base theme: test_basetheme
|
||||
libraries:
|
||||
- test_subtheme/global-styling
|
||||
stylesheets-remove:
|
||||
- '@theme_test/css/sub-remove.css'
|
||||
- '@test_basetheme/base-add.sub-remove.css'
|
|
@ -0,0 +1,6 @@
|
|||
global-styling:
|
||||
version: VERSION
|
||||
css:
|
||||
base:
|
||||
css/sub-add.css: {}
|
||||
css/samename.css: {}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Add hooks for tests to use.
|
||||
*/
|
||||
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
/**
|
||||
* Implements hook_views_pre_render().
|
||||
*/
|
||||
function test_subtheme_views_pre_render(ViewExecutable $view) {
|
||||
// We append the function name to the title for test to check for.
|
||||
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_post_render().
|
||||
*/
|
||||
function test_subtheme_views_post_render(ViewExecutable $view) {
|
||||
// We append the function name to the title for test to check for.
|
||||
$view->setTitle($view->getTitle() . ":" . __FUNCTION__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for theme_test_template_test templates.
|
||||
*/
|
||||
function test_subtheme_preprocess_theme_test_template_test(&$variables) {
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{#
|
||||
// node--1.html.twig - Dummy file for finding the template
|
||||
#}
|
||||
Node Content Dummy
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\test_theme\ThemeClass.
|
||||
*/
|
||||
|
||||
namespace Drupal\test_theme;
|
||||
|
||||
/**
|
||||
* Represents a random class, used to test if themes can provide classes.
|
||||
*/
|
||||
class ThemeClass { }
|
|
@ -0,0 +1,2 @@
|
|||
{# Output for Theme API test #}
|
||||
Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_alter().
|
|
@ -0,0 +1,2 @@
|
|||
{# Output for Theme API test #}
|
||||
Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_alter().
|
|
@ -0,0 +1,5 @@
|
|||
{# Output for Theme API test #}
|
||||
Template overridden based on suggestion alter hook determined by the base hook.
|
||||
|
||||
<p>Theme hook suggestions:
|
||||
{{ theme_hook_suggestions|safe_join("<br />") }}</p>
|
|
@ -0,0 +1,5 @@
|
|||
{# Output for Theme API test #}
|
||||
Template matching the specific theme call.
|
||||
|
||||
<p>Theme hook suggestions:
|
||||
{{ theme_hook_suggestions|safe_join("<br />") }}</p>
|
|
@ -0,0 +1,2 @@
|
|||
{# Output for Theme API test #}
|
||||
Template overridden based on suggestion provided by the module declaring the theme hook.
|
|
@ -0,0 +1,2 @@
|
|||
{# Output for Theme API test #}
|
||||
Template overridden based on new theme suggestion provided by a module via hook_theme_suggestions_HOOK_alter().
|
|
@ -0,0 +1,2 @@
|
|||
{# Output for Theme API test #}
|
||||
Template overridden based on new theme suggestion provided by the test_theme theme via hook_theme_suggestions_HOOK_alter().
|
|
@ -0,0 +1,24 @@
|
|||
# Normally, themes may list CSS files like this, and if they exist in the theme
|
||||
# folder, then they get added to the page. If they have the same file name as a
|
||||
# module CSS file, then the theme's version overrides the module's version, so
|
||||
# that the module's version is not added to the page. Additionally, a theme may
|
||||
# have an entry like this one, without having the corresponding CSS file in the
|
||||
# theme's folder, and in this case, it just stops the module's version from
|
||||
# being loaded, and does not replace it with an alternate version. We have this
|
||||
# here in order for a test to ensure that this correctly prevents the module
|
||||
# version from being loaded, and that errors aren't caused by the lack of this
|
||||
# file within the theme folder.
|
||||
name: 'Test theme'
|
||||
type: theme
|
||||
description: 'Theme for testing the theme system'
|
||||
version: VERSION
|
||||
base theme: classy
|
||||
core: 8.x
|
||||
stylesheets-remove:
|
||||
- '@system/css/system.module.css'
|
||||
libraries:
|
||||
- test_theme/global-styling
|
||||
regions:
|
||||
content: Content
|
||||
left: Left
|
||||
right: Right
|
|
@ -0,0 +1,5 @@
|
|||
global-styling:
|
||||
version: VERSION
|
||||
css:
|
||||
base:
|
||||
kitten.css: {}
|
107
core/modules/system/tests/themes/test_theme/test_theme.theme
Normal file
107
core/modules/system/tests/themes/test_theme/test_theme.theme
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Theme to help test the Twig engine.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements THEME_preprocess_twig_theme_test_php_variables().
|
||||
*/
|
||||
function test_theme_preprocess_twig_theme_test_php_variables(&$variables) {
|
||||
$variables['php_values'] = _test_theme_twig_php_values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a theme overriding a suggestion of a base theme hook.
|
||||
*/
|
||||
function test_theme_theme_test__suggestion($variables) {
|
||||
return 'Theme hook implementor=test_theme_theme_test__suggestion(). Foo=' . $variables['foo'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_element_info_alter().
|
||||
*/
|
||||
function test_theme_element_info_alter(&$info) {
|
||||
// Decrease the default size of textfields.
|
||||
if (isset($info['textfield']['#size'])) {
|
||||
$info['textfield']['#size'] = 40;
|
||||
}
|
||||
}
|
||||
|
||||
function test_theme_library_info_alter(&$libraries) {
|
||||
$libraries['kitten']['js'][] = 'kittens.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a theme implementing an alter hook.
|
||||
*
|
||||
* The confusing function name here is due to this being an implementation of
|
||||
* the alter hook invoked when the 'theme_test' module calls
|
||||
* \Drupal::moduleHandler->alter('theme_test_alter').
|
||||
*/
|
||||
function test_theme_theme_test_alter_alter(&$data) {
|
||||
$data = 'test_theme_theme_test_alter_alter was invoked';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_alter().
|
||||
*/
|
||||
function test_theme_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
|
||||
drupal_set_message(__FUNCTION__ . '() executed.');
|
||||
// Theme alter hooks run after module alter hooks, so add this theme
|
||||
// suggestion to the beginning of the array so that the suggestion added by
|
||||
// the theme_suggestions_test module can be picked up when that module is
|
||||
// enabled.
|
||||
if ($hook == 'theme_test_general_suggestions') {
|
||||
array_unshift($suggestions, 'theme_test_general_suggestions__' . 'theme_override');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK_alter().
|
||||
*/
|
||||
function test_theme_theme_suggestions_theme_test_suggestions_alter(array &$suggestions, array $variables) {
|
||||
drupal_set_message(__FUNCTION__ . '() executed.');
|
||||
// Theme alter hooks run after module alter hooks, so add this theme
|
||||
// suggestion to the beginning of the array so that the suggestion added by
|
||||
// the theme_suggestions_test module can be picked up when that module is
|
||||
// enabled.
|
||||
array_unshift($suggestions, 'theme_test_suggestions__' . 'theme_override');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK_alter().
|
||||
*/
|
||||
function test_theme_theme_suggestions_theme_test_function_suggestions_alter(array &$suggestions, array $variables) {
|
||||
// Theme alter hooks run after module alter hooks, so add this theme
|
||||
// suggestion to the beginning of the array so that the suggestion added by
|
||||
// the theme_suggestions_test module can be picked up when that module is
|
||||
// enabled.
|
||||
array_unshift($suggestions, 'theme_test_function_suggestions__' . 'theme_override');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for a theme function suggestion test.
|
||||
*
|
||||
* Implements the theme_test_function_suggestions__theme_override suggestion.
|
||||
*/
|
||||
function test_theme_theme_test_function_suggestions__theme_override($variables) {
|
||||
return 'Theme function overridden based on new theme suggestion provided by the test_theme theme.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTML for a theme function suggestion test.
|
||||
*
|
||||
* Implements the theme_test_function_suggestions__module_override suggestion.
|
||||
*/
|
||||
function test_theme_theme_test_function_suggestions__module_override($variables) {
|
||||
return 'Theme function overridden based on new theme suggestion provided by a module.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_registry_alter().
|
||||
*/
|
||||
function test_theme_theme_registry_alter(&$registry) {
|
||||
$registry['theme_test_template_test']['variables']['additional'] = 'value';
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
{# Output for Theme API test #}
|
||||
Success: Template overrides theme function.
|
|
@ -0,0 +1,2 @@
|
|||
{# Output for Theme API test #}
|
||||
Success: Template overridden.
|
|
@ -0,0 +1,4 @@
|
|||
type: theme
|
||||
core: 8.x
|
||||
name: 'Test theme with a too long name'
|
||||
version: VERSION
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
// node--1.tpl.php - Dummy file for finding the template
|
||||
?>
|
||||
Node Content Dummy
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Test theme PHPTemplate'
|
||||
type: theme
|
||||
description: 'Theme for testing the theme system with the PHPTemplate engine'
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
engine: phptemplate
|
|
@ -0,0 +1 @@
|
|||
<?php
|
|
@ -0,0 +1,2 @@
|
|||
<!-- Output for Theme API test -->
|
||||
<?php print 'Success: Template overridden with PHPTemplate theme.'; ?>
|
|
@ -0,0 +1,5 @@
|
|||
This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-extend.html.twig
|
||||
|
||||
{% block content %}
|
||||
This text is in a block.
|
||||
{% endblock %}
|
|
@ -0,0 +1 @@
|
|||
This line is from test_theme_twig_registry_loader/templates/twig-registry-loader-test-include.html.twig
|
|
@ -0,0 +1,5 @@
|
|||
name: 'Twig registry loader test'
|
||||
type: theme
|
||||
description: 'Support module for Twig registry loader testing.'
|
||||
version: VERSION
|
||||
core: 8.x
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Twig registry loader test subtheme'
|
||||
type: theme
|
||||
base theme: test_theme_twig_registry_loader_theme
|
||||
description: 'Support module for Twig registry loader testing.'
|
||||
version: VERSION
|
||||
core: 8.x
|
|
@ -0,0 +1,5 @@
|
|||
This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-extend.html.twig
|
||||
|
||||
{% block content %}
|
||||
This text is in a block.
|
||||
{% endblock %}
|
|
@ -0,0 +1 @@
|
|||
This line is from test_theme_twig_registry_loader_theme/templates/twig-registry-loader-test-include.html.twig
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Twig registry loader test theme'
|
||||
type: theme
|
||||
base theme: test_theme_twig_registry_loader
|
||||
description: 'Support module for Twig registry loader testing.'
|
||||
version: VERSION
|
||||
core: 8.x
|
Reference in a new issue