Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\system\Tests\Theme\EnginePhpTemplateTest.
* Contains \Drupal\system\Tests\Theme\EngineNyanCatTest.
*/
namespace Drupal\system\Tests\Theme;
@ -10,11 +10,11 @@ namespace Drupal\system\Tests\Theme;
use Drupal\simpletest\WebTestBase;
/**
* Tests theme functions with PHPTemplate.
* Tests the multi theme engine support.
*
* @group Theme
*/
class EnginePhpTemplateTest extends WebTestBase {
class EngineNyanCatTest extends WebTestBase {
/**
* Modules to enable.
@ -25,7 +25,7 @@ class EnginePhpTemplateTest extends WebTestBase {
protected function setUp() {
parent::setUp();
\Drupal::service('theme_handler')->install(array('test_theme_phptemplate'));
\Drupal::service('theme_handler')->install(array('test_theme_nyan_cat_engine'));
}
/**
@ -33,10 +33,10 @@ class EnginePhpTemplateTest extends WebTestBase {
*/
function testTemplateOverride() {
$this->config('system.theme')
->set('default', 'test_theme_phptemplate')
->set('default', 'test_theme_nyan_cat_engine')
->save();
$this->drupalGet('theme-test/template-test');
$this->assertText('Success: Template overridden with PHPTemplate theme.', 'Template overridden by PHPTemplate file.');
$this->assertText('Success: Template overridden with Nyan Cat theme. All of them', 'Template overridden by Nyan Cat file.');
}
}

View file

@ -137,4 +137,12 @@ class EngineTwigTest extends WebTestBase {
$this->assertRaw('ckeditor.js');
}
/**
* Tests the rendering of renderables.
*/
public function testRenderable() {
$this->drupalGet('/twig-theme-test/renderable');
$this->assertRaw('<div>Example markup</div>');
}
}

View file

@ -172,8 +172,9 @@ class FunctionsTest extends WebTestBase {
* Tests links.html.twig.
*/
function testLinks() {
// Turn off the query for the _l() function to compare the active
// link correctly.
// Turn off the query for the
// \Drupal\Core\Utility\LinkGeneratorInterface::generate() method to compare
// the active link correctly.
$original_query = \Drupal::request()->query->all();
\Drupal::request()->query->replace(array());
// Verify that empty variables produce no output.

View file

@ -100,6 +100,11 @@ class RegistryTest extends KernelTestBase {
'test_basetheme_preprocess_theme_test_template_test',
], $preprocess_functions);
$preprocess_functions = $registry_base_theme->get()['theme_test_function_suggestions']['preprocess functions'];
$this->assertIdentical([
'template_preprocess_theme_test_function_suggestions',
'test_basetheme_preprocess_theme_test_function_suggestions',
], $preprocess_functions, "Theme functions don't have template_preprocess but do have template_preprocess_HOOK");
}
/**

View file

@ -0,0 +1,75 @@
<?php
/**
* @file
* Contains \Drupal\system\Tests\Theme\StableThemeTest.
*/
namespace Drupal\system\Tests\Theme;
use Drupal\simpletest\KernelTestBase;
/**
* Tests the behavior of the Stable theme.
*
* @group Theme
*/
class StableThemeTest extends KernelTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = ['system'];
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->themeHandler = $this->container->get('theme_handler');
$this->themeManager = $this->container->get('theme.manager');
}
/**
* Ensures Stable is used by default when no base theme has been defined.
*/
public function testStableIsDefault() {
$this->themeHandler->install(['test_stable']);
$this->config('system.theme')->set('default', 'test_stable')->save();
$theme = $this->themeManager->getActiveTheme();
/** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
$base_themes = $theme->getBaseThemes();
$base_theme = reset($base_themes);
$this->assertTrue($base_theme->getName() == 'stable', "Stable theme is the base theme if a theme hasn't decided to opt out.");
}
/**
* Tests opting out of Stable by setting the base theme to false.
*/
public function testWildWest() {
$this->themeHandler->install(['test_wild_west']);
$this->config('system.theme')->set('default', 'test_wild_west')->save();
$theme = $this->themeManager->getActiveTheme();
/** @var \Drupal\Core\Theme\ActiveTheme $base_theme */
$base_themes = $theme->getBaseThemes();
$this->assertTrue(empty($base_themes), 'No base theme is set when a theme has opted out of using Stable.');
}
}

View file

@ -21,7 +21,7 @@ class TableTest extends KernelTestBase {
*
* @var array
*/
public static $modules = array('system');
public static $modules = ['system', 'form_test'];
/**
* {@inheritdoc}
@ -46,7 +46,9 @@ class TableTest extends KernelTestBase {
'#sticky' => TRUE,
);
$this->render($table);
$this->assertTrue(in_array('core/drupal.tableheader', $table['#attached']['library']), 'tableheader asset library found.');
// Make sure tableheader.js was attached.
$tableheader = $this->xpath("//script[contains(@src, 'tableheader.js')]");
$this->assertEqual(count($tableheader), 1);
$this->assertRaw('sticky-enabled');
}
@ -69,7 +71,9 @@ class TableTest extends KernelTestBase {
'#sticky' => FALSE,
);
$this->render($table);
$this->assertFalse(in_array('core/drupal.tableheader', $table['#attached']['library']), 'tableheader asset library not found.');
// Make sure tableheader.js was not attached.
$tableheader = $this->xpath("//script[contains(@src, 'tableheader.js')]");
$this->assertEqual(count($tableheader), 0);
$this->assertNoRaw('sticky-enabled');
}
@ -308,4 +312,15 @@ class TableTest extends KernelTestBase {
$this->assertRaw('<tbody><tr><td>1-one</td><td>1-two</td><td>1-three</td></tr>', 'Table row 1 found.');
$this->assertRaw('<tr><td>2-one</td><td>2-two</td><td><b>2-three</b></td></tr></tbody>', 'Table row 2 found.');
}
/**
* Tests that the select/checkbox label is being generated and escaped.
*/
public function testThemeTableTitle() {
$form = \Drupal::formBuilder()->getForm('\Drupal\form_test\Form\FormTestTableForm');
$this->render($form);
$this->assertEscaped('Update <em>kitten</em>');
$this->assertRaw('Update my favourite fruit is <strong>bananas</strong>');
}
}

View file

@ -33,6 +33,6 @@ class ThemeEarlyInitializationTest extends WebTestBase {
$this->assertRaw('Themed output generated in a KernelEvents::REQUEST listener');
// Verify that the default theme's CSS still appears even though the theme
// system was initialized early.
$this->assertRaw('classy/css/layout.css');
$this->assertRaw('classy/css/components/action-links.css');
}
}

View file

@ -71,16 +71,16 @@ class ThemeInfoTest extends WebTestBase {
// should work nevertheless.
$this->drupalGet('theme-test/info/stylesheets');
$this->assertIdentical(1, count($this->xpath('//style[contains(text(), :text)]', array(':text' => "$base/base-add.css"))), "$base/base-add.css found");
$this->assertIdentical(0, count($this->xpath('//style[contains(text(), :text)]', array(':text' => "base-remove.css"))), "base-remove.css not found");
$this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$base/base-add.css"))), "$base/base-add.css found");
$this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "base-remove.css"))), "base-remove.css not found");
$this->assertIdentical(1, count($this->xpath('//style[contains(text(), :text)]', array(':text' => "$sub/sub-add.css"))), "$sub/sub-add.css found");
$this->assertIdentical(0, count($this->xpath('//style[contains(text(), :text)]', array(':text' => "sub-remove.css"))), "sub-remove.css not found");
$this->assertIdentical(0, count($this->xpath('//style[contains(text(), :text)]', array(':text' => "base-add.sub-remove.css"))), "base-add.sub-remove.css not found");
$this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$sub/sub-add.css"))), "$sub/sub-add.css found");
$this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "sub-remove.css"))), "sub-remove.css not found");
$this->assertIdentical(0, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "base-add.sub-remove.css"))), "base-add.sub-remove.css not found");
// Verify that CSS files with the same name are loaded from both the base theme and subtheme.
$this->assertIdentical(1, count($this->xpath('//style[contains(text(), :text)]', array(':text' => "$base/samename.css"))), "$base/samename.css found");
$this->assertIdentical(1, count($this->xpath('//style[contains(text(), :text)]', array(':text' => "$sub/samename.css"))), "$sub/samename.css found");
$this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$base/samename.css"))), "$base/samename.css found");
$this->assertIdentical(1, count($this->xpath('//link[contains(@href, :href)]', array(':href' => "$sub/samename.css"))), "$sub/samename.css found");
}

View file

@ -13,7 +13,7 @@ use Drupal\test_theme\ThemeClass;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Drupal\Component\Utility\SafeStringInterface;
use Drupal\Component\Render\MarkupInterface;
/**
* Tests low-level theme functions.
@ -61,13 +61,13 @@ class ThemeTest extends WebTestBase {
*/
function testThemeDataTypes() {
// theme_test_false is an implemented theme hook so \Drupal::theme() service
// should return a string or an object that implements SafeStringInterface,
// should return a string or an object that implements MarkupInterface,
// even though the theme function itself can return anything.
$foos = array('null' => NULL, 'false' => FALSE, 'integer' => 1, 'string' => 'foo', 'empty_string' => '');
foreach ($foos as $type => $example) {
$output = \Drupal::theme()->render('theme_test_foo', array('foo' => $example));
$this->assertTrue($output instanceof SafeStringInterface || is_string($output), format_string('\Drupal::theme() returns an object that implements SafeStringInterface or a string for data type !type.', array('!type' => $type)));
if ($output instanceof SafeStringInterface) {
$this->assertTrue($output instanceof MarkupInterface || is_string($output), format_string('\Drupal::theme() returns an object that implements MarkupInterface or a string for data type @type.', array('@type' => $type)));
if ($output instanceof MarkupInterface) {
$this->assertIdentical((string) $example, $output->__toString());
}
elseif (is_string($output)) {
@ -175,7 +175,7 @@ class ThemeTest extends WebTestBase {
$config->set('css.preprocess', 0);
$config->save();
$this->drupalGet('theme-test/suggestion');
$this->assertNoText('system.module.css', 'The theme\'s .info.yml file is able to override a module CSS file from being added to the page.');
$this->assertNoText('system.module.css', "The theme's .info.yml file is able to remove a module CSS file from being added to the page.");
// Also test with aggregation enabled, simply ensuring no PHP errors are
// triggered during drupal_build_css_cache() when a source file doesn't

View file

@ -65,6 +65,35 @@ class TwigEnvironmentTest extends KernelTestBase {
// Render it twice so that twig caching is triggered.
$this->assertEqual($renderer->renderRoot($element), 'test-with-context muuh');
$this->assertEqual($renderer->renderRoot($element_copy), 'test-with-context muuh');
// Tests caching of inline templates with long content to ensure the
// generated cache key can be used as a filename.
$element = [];
$element['test'] = [
'#type' => 'inline_template',
'#template' => 'Llamas sometimes spit and wrestle with their {{ llama }}. Kittens are soft and fuzzy and they sometimes say {{ kitten }}. Flamingos have long legs and they are usually {{ flamingo }}. Pandas eat bamboo and they are {{ panda }}. Giraffes have long necks and long tongues and they eat {{ giraffe }}.',
'#context' => [
'llama' => 'necks',
'kitten' => 'meow',
'flamingo' => 'pink',
'panda' => 'bears',
'giraffe' => 'leaves',
],
];
$expected = 'Llamas sometimes spit and wrestle with their necks. Kittens are soft and fuzzy and they sometimes say meow. Flamingos have long legs and they are usually pink. Pandas eat bamboo and they are bears. Giraffes have long necks and long tongues and they eat leaves.';
$element_copy = $element;
// Render it twice so that twig caching is triggered.
$this->assertEqual($renderer->renderRoot($element), $expected);
$this->assertEqual($renderer->renderRoot($element_copy), $expected);
$name = '{# inline_template_start #}' . $element['test']['#template'];
$hash = $this->container->getParameter('twig_extension_hash');
$cache = $environment->getCache();
$class = $environment->getTemplateClass($name);
$expected = $hash . '_inline-template' . '_' . hash('sha256', $class);
$this->assertEqual($expected, $cache->generateKey($name, $class));
}
/**

View file

@ -114,8 +114,7 @@ class TwigSettingsTest extends WebTestBase {
$this->rebuildContainer();
// This should return false after rebuilding the service container.
$new_cache_filename = $this->container->get('twig')->getCacheFilename($template_filename);
$this->assertFalse($new_cache_filename, 'Twig environment does not return cache filename after caching is disabled.');
$this->assertFalse($this->container->get('twig')->getCache(), 'Twig environment has caching disabled.');
}
/**

View file

@ -138,18 +138,13 @@ class TwigTransTest extends WebTestBase {
'{{ token }} was successfully translated and prefixed with "@".'
);
$this->assertRaw(
'PAS-THRU: &"<>',
'{{ token|passthrough }} was successfully translated and prefixed with "!".'
);
$this->assertRaw(
'PLAYSHOLDR: <em class="placeholder">&amp;&quot;&lt;&gt;</em>',
'{{ token|placeholder }} was successfully translated and prefixed with "%".'
);
$this->assertRaw(
'DIS complex token HAZ LENGTH OV: 3. IT CONTAYNZ: <em class="placeholder">12345</em> AN &amp;&quot;&lt;&gt;. LETS PAS TEH BAD TEXT THRU: &"<>.',
'DIS complex token HAZ LENGTH OV: 3. IT CONTAYNZ: <em class="placeholder">12345</em> AN &amp;&quot;&lt;&gt;.',
'{{ complex.tokens }} were successfully translated with appropriate prefixes.'
);
@ -253,14 +248,11 @@ msgstr[1] "O HAI @count STARZZZZ"
msgid "Escaped: @string"
msgstr "ESCAPEE: @string"
msgid "Pass-through: !string"
msgstr "PAS-THRU: !string"
msgid "Placeholder: %string"
msgstr "PLAYSHOLDR: %string"
msgid "This @token.name has a length of: @count. It contains: %token.numbers and @token.bad_text. Lets pass the bad text through: !token.bad_text."
msgstr "DIS @token.name HAZ LENGTH OV: @count. IT CONTAYNZ: %token.numbers AN @token.bad_text. LETS PAS TEH BAD TEXT THRU: !token.bad_text."
msgid "This @token.name has a length of: @count. It contains: %token.numbers and @token.bad_text."
msgstr "DIS @token.name HAZ LENGTH OV: @count. IT CONTAYNZ: %token.numbers AN @token.bad_text."
msgctxt "Lolspeak"
msgid "I have context."