Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713

This commit is contained in:
Pantheon Automation 2016-05-04 14:35:41 -07:00 committed by Greg Anderson
parent c0a0d5a94c
commit 9eae24d844
669 changed files with 3873 additions and 1553 deletions

View file

@ -147,4 +147,3 @@ $connection->delete('router')
$connection->delete('router')
->condition('name', 'entity.block_content_type.%', 'LIKE')
->execute();

View file

@ -6,19 +6,20 @@
* upgrade path of https://www.drupal.org/node/2354889.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// A custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2354889.yml'));
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2354889.yml'));
// A custom block without any visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2354889.yml'));
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2354889.yml'));
// A custom block with visibility settings that contain a non-existing context
// mapping.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdtestfor2354889.yml'));
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdtestfor2354889.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')

View file

@ -20,4 +20,3 @@ $connection->update('config')
$connection->insert('key_value')
->fields(['collection' => 'system.schema', 'name' => 'update_script_test', 'value' => serialize(8000)])
->execute();

View file

@ -6,12 +6,13 @@
* upgrade path of https://www.drupal.org/node/507488.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor507488.yml'));
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor507488.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')

View file

@ -6,12 +6,13 @@
* upgrade path of https://www.drupal.org/node/2476947.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2476947.yml'));
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2476947.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')

View file

@ -6,12 +6,13 @@
* upgrade path of https://www.drupal.org/node/507488.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2569529.yml'));
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2569529.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')

View file

@ -6,12 +6,13 @@
* upgrade path of https://www.drupal.org/node/2005546.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a custom block with visibility settings.
$block_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.yml'));
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')

View file

@ -37,4 +37,3 @@ $connection->update('config')
->condition('collection', '')
->condition('name', 'core.extension')
->execute();

View file

@ -36,4 +36,3 @@ $connection->update('config')
->condition('collection', '')
->condition('name', 'core.extension')
->execute();

View file

@ -6,6 +6,7 @@
* upgrade path of https://www.drupal.org/node/2455125.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
@ -13,7 +14,7 @@ $connection = Database::getConnection();
// Structure of a view with timestamp fields.
$views_configs = [];
$views_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-entity-views-data-2455125.yml'));
$views_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-entity-views-data-2455125.yml'));
foreach ($views_configs as $views_config) {
$connection->insert('config')

View file

@ -5,7 +5,9 @@
* Test fixture.
*/
$connection = Drupal\Core\Database\Database::getConnection();
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
$config = $connection;
$connection->merge('config')

View file

@ -5,8 +5,22 @@
* Simpletest mock module for Ajax forms testing.
*/
use Drupal\Core\Ajax;
use Drupal\Core\Ajax\AddCssCommand;
use Drupal\Core\Ajax\AfterCommand;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\AlertCommand;
use Drupal\Core\Ajax\AppendCommand;
use Drupal\Core\Ajax\BeforeCommand;
use Drupal\Core\Ajax\ChangedCommand;
use Drupal\Core\Ajax\CssCommand;
use Drupal\Core\Ajax\DataCommand;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\Core\Ajax\InsertCommand;
use Drupal\Core\Ajax\InvokeCommand;
use Drupal\Core\Ajax\PrependCommand;
use Drupal\Core\Ajax\RemoveCommand;
use Drupal\Core\Ajax\RestripeCommand;
use Drupal\Core\Ajax\SettingsCommand;
use Drupal\Core\Form\FormStateInterface;
/**
@ -16,7 +30,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, FormStateInterf
$selector = '#after_div';
$response = new AjaxResponse();
$response->addCommand(new Ajax\AfterCommand($selector, "This will be placed after"));
$response->addCommand(new AfterCommand($selector, "This will be placed after"));
return $response;
}
@ -25,7 +39,7 @@ function ajax_forms_test_advanced_commands_after_callback($form, FormStateInterf
*/
function ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\AlertCommand('Alert'));
$response->addCommand(new AlertCommand('Alert'));
return $response;
}
@ -35,7 +49,7 @@ function ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterf
function ajax_forms_test_advanced_commands_append_callback($form, FormStateInterface $form_state) {
$selector = '#append_div';
$response = new AjaxResponse();
$response->addCommand(new Ajax\AppendCommand($selector, "Appended text"));
$response->addCommand(new AppendCommand($selector, "Appended text"));
return $response;
}
@ -45,7 +59,7 @@ function ajax_forms_test_advanced_commands_append_callback($form, FormStateInter
function ajax_forms_test_advanced_commands_before_callback($form, FormStateInterface $form_state) {
$selector = '#before_div';
$response = new AjaxResponse();
$response->addCommand(new Ajax\BeforeCommand($selector, "Before text"));
$response->addCommand(new BeforeCommand($selector, "Before text"));
return $response;
}
@ -54,7 +68,7 @@ function ajax_forms_test_advanced_commands_before_callback($form, FormStateInter
*/
function ajax_forms_test_advanced_commands_changed_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\ChangedCommand('#changed_div'));
$response->addCommand(new ChangedCommand('#changed_div'));
return $response;
}
@ -63,7 +77,7 @@ function ajax_forms_test_advanced_commands_changed_callback($form, FormStateInte
*/
function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\ChangedCommand('#changed_div', '#changed_div_mark_this'));
$response->addCommand(new ChangedCommand('#changed_div', '#changed_div_mark_this'));
return $response;
}
@ -75,7 +89,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterfac
$color = 'blue';
$response = new AjaxResponse();
$response->addCommand(new Ajax\CssCommand($selector, array('background-color' => $color)));
$response->addCommand(new CssCommand($selector, array('background-color' => $color)));
return $response;
}
@ -85,7 +99,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterfac
function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterface $form_state) {
$selector = '#data_div';
$response = new AjaxResponse();
$response->addCommand(new Ajax\DataCommand($selector, 'testkey', 'testvalue'));
$response->addCommand(new DataCommand($selector, 'testkey', 'testvalue'));
return $response;
}
@ -94,7 +108,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterfa
*/
function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\InvokeCommand('#invoke_div', 'addClass', array('error')));
$response->addCommand(new InvokeCommand('#invoke_div', 'addClass', array('error')));
return $response;
}
@ -103,7 +117,7 @@ function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInter
*/
function ajax_forms_test_advanced_commands_html_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\HtmlCommand('#html_div', 'replacement text'));
$response->addCommand(new HtmlCommand('#html_div', 'replacement text'));
return $response;
}
@ -112,7 +126,7 @@ function ajax_forms_test_advanced_commands_html_callback($form, FormStateInterfa
*/
function ajax_forms_test_advanced_commands_insert_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\InsertCommand('#insert_div', 'insert replacement text'));
$response->addCommand(new InsertCommand('#insert_div', 'insert replacement text'));
return $response;
}
@ -121,7 +135,7 @@ function ajax_forms_test_advanced_commands_insert_callback($form, FormStateInter
*/
function ajax_forms_test_advanced_commands_prepend_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\PrependCommand('#prepend_div', "prepended text"));
$response->addCommand(new PrependCommand('#prepend_div', "prepended text"));
return $response;
}
@ -130,7 +144,7 @@ function ajax_forms_test_advanced_commands_prepend_callback($form, FormStateInte
*/
function ajax_forms_test_advanced_commands_remove_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\RemoveCommand('#remove_text'));
$response->addCommand(new RemoveCommand('#remove_text'));
return $response;
}
@ -139,7 +153,7 @@ function ajax_forms_test_advanced_commands_remove_callback($form, FormStateInter
*/
function ajax_forms_test_advanced_commands_restripe_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\RestripeCommand('#restripe_table'));
$response->addCommand(new RestripeCommand('#restripe_table'));
return $response;
}
@ -149,7 +163,7 @@ function ajax_forms_test_advanced_commands_restripe_callback($form, FormStateInt
function ajax_forms_test_advanced_commands_settings_callback($form, FormStateInterface $form_state) {
$setting['ajax_forms_test']['foo'] = 42;
$response = new AjaxResponse();
$response->addCommand(new Ajax\SettingsCommand($setting));
$response->addCommand(new SettingsCommand($setting));
return $response;
}
@ -158,7 +172,7 @@ function ajax_forms_test_advanced_commands_settings_callback($form, FormStateInt
*/
function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new Ajax\AddCssCommand('my/file.css'));
$response->addCommand(new AddCssCommand('my/file.css'));
return $response;
}

View file

@ -4,7 +4,7 @@ namespace Drupal\condition_test\Tests;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\ContextDefinition;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;
/**

View file

@ -47,4 +47,3 @@ function database_test_query_alter(AlterableInterface $query) {
function database_test_query_database_test_alter_remove_range_alter(AlterableInterface $query) {
$query->range();
}

View file

@ -52,7 +52,7 @@ class DatabaseTestForm extends FormBase {
$options[$account->id()] = array(
'title' => array('data' => array('#title' => $account->getUsername())),
'username' => $account->getUsername(),
'status' => $account->isActive() ? t('active') : t('blocked'),
'status' => $account->isActive() ? t('active') : t('blocked'),
);
}

View file

@ -63,6 +63,13 @@ class EntityTestRev extends EntityTest {
$fields['name']->setRevisionable(TRUE);
$fields['user_id']->setRevisionable(TRUE);
$fields['non_rev_field'] = BaseFieldDefinition::create('string')
->setLabel(t('Non Revisionable Field'))
->setDescription(t('A non-revisionable test field.'))
->setRevisionable(FALSE)
->setCardinality(1)
->setReadOnly(TRUE);
return $fields;
}

View file

@ -5,12 +5,13 @@
* Contains hook implementations for Entity Operation Test Module.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
/**
* Implements hook_entity_operation().
*/
function entity_test_operation_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) {
function entity_test_operation_entity_operation(EntityInterface $entity) {
return [
'test' => [
'title' => t('Front page'),

View file

@ -46,7 +46,7 @@ class ErrorTestController extends ControllerBase {
// This will generate a notice.
$monkey_love = $bananas;
// This will generate a warning.
$awesomely_big = 1/0;
$awesomely_big = 1 / 0;
// This will generate a user error. Use & to check for double escaping.
trigger_error("Drupal & awesome", E_USER_WARNING);
return [];

View file

@ -2,6 +2,8 @@
namespace Drupal\module_test\Controller;
use Drupal\module_autoload_test\SomeClass;
/**
* Controller routines for module_test routes.
*/
@ -38,7 +40,7 @@ class ModuleTestController {
public function testClassLoading() {
$markup = NULL;
if (class_exists('Drupal\module_autoload_test\SomeClass')) {
$obj = new \Drupal\module_autoload_test\SomeClass();
$obj = new SomeClass();
$markup = $obj->testMethod();
}
return ['#markup' => $markup];

View file

@ -6,4 +6,3 @@ namespace Drupal\plugin_test\Plugin\plugin_test\fruit;
* Provides an interface for test plugins.
*/
interface FruitInterface { }

View file

@ -36,10 +36,10 @@ class MockMenuBlock {
// nesting level. For depth=2, this returns:
// '<ul><li>1<ul><li>1.1</li></ul></li></ul>'.
$content = '';
for ($i=0; $i < $this->depth; $i++) {
$content .= '<ul><li>' . implode('.', array_fill(0, $i+1, '1'));
for ($i = 0; $i < $this->depth; $i++) {
$content .= '<ul><li>' . implode('.', array_fill(0, $i + 1, '1'));
}
for ($i=0; $i < $this->depth; $i++) {
for ($i = 0; $i < $this->depth; $i++) {
$content .= '</li></ul>';
}
return $content;

View file

@ -28,4 +28,3 @@ class PageCacheAcceptHeaderController {
}
}
}

View file

@ -14,7 +14,7 @@ class MockFileTransfer {
* A new Drupal\system_test\MockFileTransfer object.
*/
public static function factory() {
return new MockFileTransfer;
return new MockFileTransfer();
}
/**

View file

@ -81,7 +81,7 @@ class ThemeTestController extends ControllerBase {
* Content in theme_test_output GLOBAL.
*/
public function testRequestListener() {
return ['#markup' => $GLOBALS['theme_test_output']];
return ['#markup' => $GLOBALS['theme_test_output']];
}
/**

View file

@ -17,4 +17,3 @@ class TrustedHostsTestController {
}
}

View file

@ -20,4 +20,3 @@ function twig_extension_test_theme($existing, $type, $theme, $path) {
),
);
}

View file

@ -0,0 +1,31 @@
<?php
namespace Drupal\update_script_test\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Request;
/**
* Controller routines for update_script_test routes.
*/
class UpdateScriptTestController extends ControllerBase {
/**
* Outputs a link to the database updates URL.
*/
public function databaseUpdatesMenuItem(Request $request) {
// @todo Simplify with https://www.drupal.org/node/2548095
$base_url = str_replace('/update.php', '', $request->getBaseUrl());
$url = (new Url('system.db_update'))->setOption('base_url', $base_url);
$build['main'] = array(
'#type' => 'link',
'#title' => $this->t('Run database updates'),
'#url' => $url,
'#access' => $url->access($this->currentUser()),
);
return $build;
}
}

View file

@ -0,0 +1,6 @@
update_script_test.database_updates_menu_item:
path: '/update-script-test/database-updates-menu-item'
defaults:
_controller: '\Drupal\update_script_test\Controller\UpdateScriptTestController::databaseUpdatesMenuItem'
requirements:
_access: 'TRUE'

View file

@ -64,6 +64,6 @@ function update_test_postupdate_post_update_test_batch(&$sandbox = NULL) {
$execution[] = __FUNCTION__ . '-' . $sandbox['current_step'];
\Drupal::state()->set('post_update_test_execution', $execution);
$sandbox['#finished'] = $sandbox['current_step'] / $sandbox['steps'];
$sandbox['#finished'] = $sandbox['current_step'] / $sandbox['steps'];
return 'Test post update batches';
}

View file

@ -2,6 +2,7 @@
namespace Drupal\Tests\system\Kernel\Extension;
use Drupal\Core\Extension\MissingDependencyException;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use \Drupal\Core\Extension\ModuleUninstallValidatorException;
use Drupal\entity_test\Entity\EntityTest;
@ -121,7 +122,7 @@ class ModuleHandlerTest extends KernelTestBase {
$result = $this->moduleInstaller()->install(array('color'));
$this->fail(t('ModuleInstaller::install() throws an exception if dependencies are missing.'));
}
catch (\Drupal\Core\Extension\MissingDependencyException $e) {
catch (MissingDependencyException $e) {
$this->pass(t('ModuleInstaller::install() throws an exception if dependencies are missing.'));
}

View file

@ -0,0 +1,156 @@
<?php
namespace Drupal\Tests\system\Kernel\Token;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Generates text using placeholders for dummy content to check token
* replacement.
*
* @group system
*/
class TokenReplaceKernelTest extends TokenReplaceKernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Set the site name to something other than an empty string.
$this->config('system.site')->set('name', 'Drupal')->save();
}
/**
* Test whether token-replacement works in various contexts.
*/
public function testSystemTokenRecognition() {
// Generate prefixes and suffixes for the token context.
$tests = array(
array('prefix' => 'this is the ', 'suffix' => ' site'),
array('prefix' => 'this is the', 'suffix' => 'site'),
array('prefix' => '[', 'suffix' => ']'),
array('prefix' => '', 'suffix' => ']]]'),
array('prefix' => '[[[', 'suffix' => ''),
array('prefix' => ':[:', 'suffix' => '--]'),
array('prefix' => '-[-', 'suffix' => ':]:'),
array('prefix' => '[:', 'suffix' => ']'),
array('prefix' => '[site:', 'suffix' => ':name]'),
array('prefix' => '[site:', 'suffix' => ']'),
);
// Check if the token is recognized in each of the contexts.
foreach ($tests as $test) {
$input = $test['prefix'] . '[site:name]' . $test['suffix'];
$expected = $test['prefix'] . 'Drupal' . $test['suffix'];
$output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()));
$this->assertTrue($output == $expected, format_string('Token recognized in string %string', array('%string' => $input)));
}
// Test token replacement when the string contains no tokens.
$this->assertEqual($this->tokenService->replace('No tokens here.'), 'No tokens here.');
}
/**
* Tests the clear parameter.
*/
public function testClear() {
// Valid token.
$source = '[site:name]';
// No user passed in, should be untouched.
$source .= '[user:name]';
// Non-existing token.
$source .= '[bogus:token]';
// Replace with the clear parameter, only the valid token should remain.
$target = Html::escape($this->config('system.site')->get('name'));
$result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId(), 'clear' => TRUE));
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
$target .= '[user:name]';
$target .= '[bogus:token]';
$result = $this->tokenService->replace($source, array(), array('langcode' => $this->interfaceLanguage->getId()));
$this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.');
}
/**
* Tests the generation of all system site information tokens.
*/
public function testSystemSiteTokenReplacement() {
$url_options = array(
'absolute' => TRUE,
'language' => $this->interfaceLanguage,
);
$slogan = '<blink>Slogan</blink>';
$safe_slogan = Xss::filterAdmin($slogan);
// Set a few site variables.
$config = $this->config('system.site');
$config
->set('name', '<strong>Drupal<strong>')
->set('slogan', $slogan)
->set('mail', 'simpletest@example.com')
->save();
// Generate and test tokens.
$tests = array();
$tests['[site:name]'] = Html::escape($config->get('name'));
$tests['[site:slogan]'] = $safe_slogan;
$tests['[site:mail]'] = $config->get('mail');
$tests['[site:url]'] = \Drupal::url('<front>', [], $url_options);
$tests['[site:url-brief]'] = preg_replace(array('!^https?://!', '!/$!'), '', \Drupal::url('<front>', [], $url_options));
$tests['[site:login-url]'] = \Drupal::url('user.page', [], $url_options);
$base_bubbleable_metadata = new BubbleableMetadata();
$metadata_tests = [];
$metadata_tests['[site:name]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$metadata_tests['[site:slogan]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$metadata_tests['[site:mail]'] = BubbleableMetadata::createFromObject(\Drupal::config('system.site'));
$bubbleable_metadata = clone $base_bubbleable_metadata;
$metadata_tests['[site:url]'] = $bubbleable_metadata->addCacheContexts(['url.site']);
$metadata_tests['[site:url-brief]'] = $bubbleable_metadata;
$metadata_tests['[site:login-url]'] = $bubbleable_metadata;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
$output = $this->tokenService->replace($input, array(), array('langcode' => $this->interfaceLanguage->getId()), $bubbleable_metadata);
$this->assertEqual($output, $expected, new FormattableMarkup('System site information token %token replaced.', ['%token' => $input]));
$this->assertEqual($bubbleable_metadata, $metadata_tests[$input]);
}
}
/**
* Tests the generation of all system date tokens.
*/
public function testSystemDateTokenReplacement() {
// Set time to one hour before request.
$date = REQUEST_TIME - 3600;
// Generate and test tokens.
$tests = array();
$date_formatter = \Drupal::service('date.formatter');
$tests['[date:short]'] = $date_formatter->format($date, 'short', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:medium]'] = $date_formatter->format($date, 'medium', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:long]'] = $date_formatter->format($date, 'long', '', NULL, $this->interfaceLanguage->getId());
$tests['[date:custom:m/j/Y]'] = $date_formatter->format($date, 'custom', 'm/j/Y', NULL, $this->interfaceLanguage->getId());
$tests['[date:since]'] = $date_formatter->formatTimeDiffSince($date, array('langcode' => $this->interfaceLanguage->getId()));
$tests['[date:raw]'] = Xss::filter($date);
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$output = $this->tokenService->replace($input, array('date' => $date), array('langcode' => $this->interfaceLanguage->getId()));
$this->assertEqual($output, $expected, format_string('Date token %token replaced.', array('%token' => $input)));
}
}
}

View file

@ -0,0 +1,43 @@
<?php
namespace Drupal\Tests\system\Kernel\Token;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
/**
* Base class for token replacement tests.
*/
abstract class TokenReplaceKernelTestBase extends EntityKernelTestBase {
/**
* The interface language.
*
* @var \Drupal\Core\Language\LanguageInterface
*/
protected $interfaceLanguage;
/**
* Token service.
*
* @var \Drupal\Core\Utility\Token
*/
protected $tokenService;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('system');
protected function setUp() {
parent::setUp();
// Install default system configuration.
$this->installConfig(array('system'));
\Drupal::service('router.builder')->rebuild();
$this->interfaceLanguage = \Drupal::languageManager()->getCurrentLanguage();
$this->tokenService = \Drupal::token();
}
}

View file

@ -142,7 +142,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([], $breadcrumb->getLinks());
$this->assertEquals(['url.path'], $breadcrumb->getCacheContexts());
$this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@ -159,7 +159,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
$this->assertEquals(['url.path'], $breadcrumb->getCacheContexts());
$this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@ -194,7 +194,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Example', new Url('example'))], $breadcrumb->getLinks());
$this->assertEquals(['url.path', 'user.permissions'], $breadcrumb->getCacheContexts());
$this->assertEquals(['url.path.parent', 'user.permissions'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@ -245,7 +245,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
new Link('Example', new Url('example')),
new Link('Bar', new Url('example_bar')),
], $breadcrumb->getLinks());
$this->assertEquals(['bar', 'url.path', 'user.permissions'], $breadcrumb->getCacheContexts());
$this->assertEquals(['bar', 'url.path.parent', 'user.permissions'], $breadcrumb->getCacheContexts());
$this->assertEquals(['example'], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@ -272,7 +272,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
$this->assertEquals(['url.path'], $breadcrumb->getCacheContexts());
$this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@ -316,7 +316,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
$this->assertEquals(['url.path'], $breadcrumb->getCacheContexts());
$this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@ -364,7 +364,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))], $breadcrumb->getLinks());
$this->assertEquals(['url.path', 'user.permissions'], $breadcrumb->getCacheContexts());
$this->assertEquals(['url.path.parent', 'user.permissions'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}

View file

@ -29,7 +29,7 @@ class InstallTranslationFilePatternTest extends UnitTestCase {
parent::setUp();
$this->fileTranslation = new FileTranslation('filename');
$method = new \ReflectionMethod('\Drupal\Core\StringTranslation\Translator\FileTranslation', 'getTranslationFilesPattern');
$method->setAccessible(true);
$method->setAccessible(TRUE);
$this->filePatternMethod = $method;
}

View file

@ -6,12 +6,13 @@ use Drupal\system\SystemRequirements;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass Drupal\system\SystemRequirements
* @coversDefaultClass \Drupal\system\SystemRequirements
* @group system
*/
class SystemRequirementsTest extends UnitTestCase {
/**
* @covers ::phpVersionWithPdoDisallowMultipleStatements
* @dataProvider providerTestPhpVersionWithPdoDisallowMultipleStatements
*/
public function testPhpVersionWithPdoDisallowMultipleStatements($version, $expected) {

View file

@ -10,4 +10,3 @@
*/
function test_subsubtheme_preprocess_theme_test_template_test(&$variables) {
}