Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2
This commit is contained in:
parent
23ffed3665
commit
507b45a0ed
378 changed files with 11434 additions and 5542 deletions
|
@ -1,9 +1,8 @@
|
|||
# The menu_settings migration is in the menu_ui module.
|
||||
id: menu
|
||||
id: d6_menu
|
||||
label: Menus
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: menu
|
||||
process:
|
20
core/modules/system/migration_templates/d7_menu.yml
Normal file
20
core/modules/system/migration_templates/d7_menu.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
id: d7_menu
|
||||
label: Menus
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: menu
|
||||
process:
|
||||
id:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: menu_name
|
||||
map:
|
||||
main-menu: main
|
||||
management: admin
|
||||
navigation: tools
|
||||
user-menu: account
|
||||
label: title
|
||||
description: description
|
||||
destination:
|
||||
plugin: entity:menu
|
|
@ -39,7 +39,7 @@ class DialogTest extends AjaxTestBase {
|
|||
'data' => $dialog_contents,
|
||||
'dialogOptions' => array(
|
||||
'modal' => TRUE,
|
||||
'title' => 'AJAX Dialog contents',
|
||||
'title' => 'AJAX Dialog & contents',
|
||||
),
|
||||
);
|
||||
$form_expected_response = array(
|
||||
|
@ -67,7 +67,7 @@ class DialogTest extends AjaxTestBase {
|
|||
'data' => $dialog_contents,
|
||||
'dialogOptions' => array(
|
||||
'modal' => FALSE,
|
||||
'title' => 'AJAX Dialog contents',
|
||||
'title' => 'AJAX Dialog & contents',
|
||||
),
|
||||
);
|
||||
$no_target_expected_response = array(
|
||||
|
@ -77,7 +77,7 @@ class DialogTest extends AjaxTestBase {
|
|||
'data' => $dialog_contents,
|
||||
'dialogOptions' => array(
|
||||
'modal' => FALSE,
|
||||
'title' => 'AJAX Dialog contents',
|
||||
'title' => 'AJAX Dialog & contents',
|
||||
),
|
||||
);
|
||||
$close_expected_response = array(
|
||||
|
@ -97,6 +97,9 @@ class DialogTest extends AjaxTestBase {
|
|||
// Emulate going to the JS version of the page and check the JSON response.
|
||||
$ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
|
||||
$this->assertEqual($modal_expected_response, $ajax_result[3], 'Modal dialog JSON response matches.');
|
||||
// Test the HTML escaping of & character.
|
||||
$this->assertEqual($ajax_result[3]['dialogOptions']['title'], 'AJAX Dialog & contents');
|
||||
$this->assertNotEqual($ajax_result[3]['dialogOptions']['title'], 'AJAX Dialog & contents');
|
||||
|
||||
// Check that requesting a "normal" dialog without JS goes to a page.
|
||||
$this->drupalGet('ajax-test/dialog-contents');
|
||||
|
@ -152,6 +155,8 @@ class DialogTest extends AjaxTestBase {
|
|||
|
||||
// Check that the response matches the expected value.
|
||||
$this->assertEqual($modal_expected_response, $ajax_result[4], 'POST request modal dialog JSON response matches.');
|
||||
// Test the HTML escaping of & character.
|
||||
$this->assertNotEqual($ajax_result[4]['dialogOptions']['title'], 'AJAX Dialog & contents');
|
||||
|
||||
// Abbreviated test for "normal" dialogs, testing only the difference.
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(), 'button2');
|
||||
|
|
|
@ -77,46 +77,4 @@ class FormatDateTest extends WebTestBase {
|
|||
$this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'fallback'), 'Test format_date() defaulting to `fallback` when $type not found.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the format_date() function.
|
||||
*/
|
||||
function testFormatDate() {
|
||||
$timestamp = strtotime('2007-03-26T00:00:00+00:00');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test translated format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'l, 25-Mar-07 17:00:00 PDT', 'Test an escaped format string.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\domingo, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash character.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\l, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash followed by escaped format string.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
|
||||
|
||||
// Change the default language and timezone.
|
||||
$this->config('system.site')->set('default_langcode', static::LANGCODE)->save();
|
||||
date_default_timezone_set('America/Los_Angeles');
|
||||
|
||||
// Reset the language manager so new negotiations attempts will fall back on
|
||||
// on the new language.
|
||||
$this->container->get('language_manager')->reset();
|
||||
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test custom date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'long'), 'domingo, 25. marzo 2007 - 17:00', 'Test long date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'medium'), '25. marzo 2007 - 17:00', 'Test medium date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'short'), '2007 Mar 25 - 5:00pm', 'Test short date format.');
|
||||
$this->assertIdentical(format_date($timestamp), '25. marzo 2007 - 17:00', 'Test default date format.');
|
||||
// Test HTML time element formats.
|
||||
$this->assertIdentical(format_date($timestamp, 'html_datetime'), '2007-03-25T17:00:00-0700', 'Test html_datetime date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_date'), '2007-03-25', 'Test html_date date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_time'), '17:00:00', 'Test html_time date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_yearless_date'), '03-25', 'Test html_yearless_date date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_week'), '2007-W12', 'Test html_week date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_month'), '2007-03', 'Test html_month date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_year'), '2007', 'Test html_year date format.');
|
||||
|
||||
// HTML is not escaped by the date formatter, it must be escaped later.
|
||||
$formatter = \Drupal::service('date.formatter');
|
||||
$this->assertIdentical($formatter->format($timestamp, 'custom', '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'Y\'\)\;\<\/\s\c\r\i\p\t\>'), "<script>alert('2007');</script>", 'Script tags not removed from dates.');
|
||||
$this->assertIdentical($formatter->format($timestamp, 'custom', '\<\e\m\>Y\<\/\e\m\>'), '<em>2007</em>', 'Em tags are not removed from dates.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,13 @@ use Drupal\simpletest\WebTestBase;
|
|||
*/
|
||||
class AjaxPageStateTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['node', 'views'];
|
||||
|
||||
/**
|
||||
* User account with all available permissions
|
||||
*
|
||||
|
@ -77,22 +84,16 @@ class AjaxPageStateTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test if multiple libaries can be excluded.
|
||||
* Test if multiple libraries can be excluded.
|
||||
*
|
||||
* ajax_page_state[libraries] should be able to support multiple libraries
|
||||
* The ajax_page_state[libraries] should be able to support multiple libraries
|
||||
* comma separated.
|
||||
*/
|
||||
public function testMultipleLibrariesAreNotLoaded() {
|
||||
$this->drupalGet('node',
|
||||
array(
|
||||
"query" =>
|
||||
array(
|
||||
'ajax_page_state' => array(
|
||||
'libraries' => 'core/html5shiv,core/drupalSettings'
|
||||
)
|
||||
)
|
||||
)
|
||||
['query' => ['ajax_page_state' => ['libraries' => 'core/html5shiv,core/drupalSettings']]]
|
||||
);
|
||||
$this->assertResponse(200);
|
||||
$this->assertNoRaw(
|
||||
'/core/assets/vendor/html5shiv/html5shiv.min.js',
|
||||
'The html5shiv library from core should be excluded from loading.'
|
||||
|
@ -102,6 +103,17 @@ class AjaxPageStateTest extends WebTestBase {
|
|||
'/core/misc/drupalSettingsLoader.js',
|
||||
'The drupalSettings library from core should be excluded from loading.'
|
||||
);
|
||||
|
||||
$this->drupalGet('node');
|
||||
$this->assertRaw(
|
||||
'/core/assets/vendor/html5shiv/html5shiv.min.js',
|
||||
'The html5shiv library from core should be included in loading.'
|
||||
);
|
||||
|
||||
$this->assertRaw(
|
||||
'/core/misc/drupalSettingsLoader.js',
|
||||
'The drupalSettings library from core should be included in loading.'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\system\Tests\Theme;
|
||||
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
|
@ -75,12 +76,16 @@ class EngineTwigTest extends WebTestBase {
|
|||
/** @var \Drupal\Core\Utility\LinkGenerator $link_generator */
|
||||
$link_generator = $this->container->get('link_generator');
|
||||
|
||||
|
||||
$generated_url = Url::fromRoute('user.register', [], ['absolute' => TRUE])->toString(TRUE)->getGeneratedUrl();
|
||||
$expected = [
|
||||
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['absolute' => TRUE])),
|
||||
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['absolute' => TRUE, 'attributes' => ['foo' => 'bar']])),
|
||||
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['foo' => 'bar', 'id' => 'kitten']])),
|
||||
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['id' => 'kitten']])),
|
||||
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['class' => ['llama', 'kitten', 'panda']]])),
|
||||
'link via the linkgenerator: ' . $link_generator->generate(Markup::create('<span>register</span>'), new Url('user.register', [], ['absolute' => TRUE])),
|
||||
'link via the linkgenerator: <a href="' . $generated_url . '"><span>register</span><svg></svg></a>',
|
||||
];
|
||||
|
||||
// Verify that link() has the ability to bubble cacheability metadata:
|
||||
|
|
|
@ -276,7 +276,7 @@ function system_requirements($phase) {
|
|||
if (empty($drivers)) {
|
||||
$database_ok = FALSE;
|
||||
$pdo_message = t('Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that <a href=":drupal-databases">Drupal supports</a>.', array(
|
||||
':drupal-databases' => 'https://www.drupal.org/node/270#database',
|
||||
':drupal-databases' => 'https://www.drupal.org/requirements/database',
|
||||
));
|
||||
}
|
||||
// Make sure the native PDO extension is available, not the older PEAR
|
||||
|
|
|
@ -59,6 +59,7 @@ drupal.system.modules:
|
|||
- core/drupal
|
||||
- core/drupal.debounce
|
||||
- core/jquery.once
|
||||
- core/drupal.announce
|
||||
|
||||
diff:
|
||||
version: VERSION
|
||||
|
|
|
@ -623,7 +623,7 @@ function system_page_attachments(array &$page) {
|
|||
// Handle setting the "active" class on links by:
|
||||
// - loading the active-link library if the current user is authenticated;
|
||||
// - applying a response filter if the current user is anonymous.
|
||||
// @see l()
|
||||
// @see \Drupal\Core\Link
|
||||
// @see \Drupal\Core\Utility\LinkGenerator::generate()
|
||||
// @see template_preprocess_links()
|
||||
// @see \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter
|
||||
|
@ -655,15 +655,6 @@ function system_js_settings_build(&$settings, AttachedAssetsInterface $assets) {
|
|||
// @see \Drupal\Core\Theme\AjaxBasePageNegotiator
|
||||
$theme_key = \Drupal::theme()->getActiveTheme()->getName();
|
||||
$settings['ajaxPageState']['theme'] = $theme_key;
|
||||
|
||||
// Provide the page with information about the individual asset libraries
|
||||
// used, information not otherwise available when aggregation is enabled.
|
||||
$minimal_libraries = $library_dependency_resolver->getMinimalRepresentativeSubset(array_merge(
|
||||
$assets->getLibraries(),
|
||||
$assets->getAlreadyLoadedLibraries()
|
||||
));
|
||||
sort($minimal_libraries);
|
||||
$settings['ajaxPageState']['libraries'] = implode(',', $minimal_libraries);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,7 +706,7 @@ function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
|
|||
$settings['pluralDelimiter'] = LOCALE_PLURAL_DELIMITER;
|
||||
}
|
||||
// Add the theme token to ajaxPageState, ensuring the database is available
|
||||
// before doing so.
|
||||
// before doing so. Also add the loaded libraries to ajaxPageState.
|
||||
/** @var \Drupal\Core\Asset\LibraryDependencyResolver $library_dependency_resolver */
|
||||
$library_dependency_resolver = \Drupal::service('library.dependency_resolver');
|
||||
if (isset($settings['ajaxPageState']) || in_array('core/drupal.ajax', $library_dependency_resolver->getLibrariesWithDependencies($assets->getAlreadyLoadedLibraries()))) {
|
||||
|
@ -729,6 +720,14 @@ function system_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
|
|||
->get($active_theme_key);
|
||||
}
|
||||
}
|
||||
// Provide the page with information about the individual asset libraries
|
||||
// used, information not otherwise available when aggregation is enabled.
|
||||
$minimal_libraries = $library_dependency_resolver->getMinimalRepresentativeSubset(array_merge(
|
||||
$assets->getLibraries(),
|
||||
$assets->getAlreadyLoadedLibraries()
|
||||
));
|
||||
sort($minimal_libraries);
|
||||
$settings['ajaxPageState']['libraries'] = implode(',', $minimal_libraries);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* - root_path: The root path of the current page (e.g., node, admin, user).
|
||||
* - node_type: The content type for the current node, if the page is a node.
|
||||
* - head_title: List of text elements that make up the head_title variable.
|
||||
* May contain or more of the following:
|
||||
* May contain one or more of the following:
|
||||
* - title: The title of the page.
|
||||
* - name: The name of the site.
|
||||
* - slogan: The slogan of the site.
|
||||
|
|
|
@ -23,7 +23,7 @@ class AjaxTestController {
|
|||
public static function dialogContents() {
|
||||
// This is a regular render array; the keys do not have special meaning.
|
||||
$content = array(
|
||||
'#title' => 'AJAX Dialog contents',
|
||||
'#title' => '<em>AJAX Dialog & contents</em>',
|
||||
'content' => array(
|
||||
'#markup' => 'Example message',
|
||||
),
|
||||
|
|
|
@ -93,7 +93,7 @@ class AjaxTestDialogForm extends FormBase {
|
|||
protected function dialog($is_modal = FALSE) {
|
||||
$content = AjaxTestController::dialogContents();
|
||||
$response = new AjaxResponse();
|
||||
$title = $this->t('AJAX Dialog contents');
|
||||
$title = $this->t('AJAX Dialog & contents');
|
||||
|
||||
// Attach the library necessary for using the Open(Modal)DialogCommand and
|
||||
// set the attachments for this Ajax response.
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\condition_test\Plugin\Condition;
|
||||
|
||||
use Drupal\Core\Condition\ConditionPluginBase;
|
||||
|
||||
/**
|
||||
* Provides a condition that has a no existing context.
|
||||
*
|
||||
* @Condition(
|
||||
* id = "condition_test_no_existing_type",
|
||||
* label = @Translation("No existing type"),
|
||||
* context = {
|
||||
* "no_existing_type" = @ContextDefinition("no_existing_type", label = @Translation("No existing type")),
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class ConditionTestNoExistingType extends ConditionPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function evaluate() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function summary() {
|
||||
return $this->t('Condition that requires a non-existent context.');
|
||||
}
|
||||
|
||||
}
|
|
@ -674,14 +674,25 @@ function _entity_test_record_hooks($hook, $data) {
|
|||
* Implements hook_entity_prepare_view().
|
||||
*/
|
||||
function entity_test_entity_prepare_view($entity_type, array $entities, array $displays) {
|
||||
// Add a dummy field item attribute on field_test_text if it exists.
|
||||
if ($entity_type == 'entity_test') {
|
||||
foreach ($entities as $entity) {
|
||||
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
|
||||
// Add a dummy field item attribute on field_test_text if it exists.
|
||||
if ($entity->hasField('field_test_text') && $displays[$entity->bundle()]->getComponent('field_test_text')) {
|
||||
foreach ($entity->get('field_test_text') as $item) {
|
||||
$item->_attributes += array('data-field-item-attr' => 'foobar');
|
||||
}
|
||||
}
|
||||
|
||||
// Add a dummy field item attribute on daterange fields if they exist.
|
||||
$fields = $entity->getFieldDefinitions();
|
||||
foreach ($fields as $field) {
|
||||
if ($field->getType() === 'daterange') {
|
||||
$item = $entity->get($field->getName());
|
||||
$item->_attributes += array('data-field-item-attr' => 'foobar');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -358,6 +358,14 @@ form_test.label:
|
|||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
form_test.machine_name:
|
||||
path: '/form-test/machine-name'
|
||||
defaults:
|
||||
_form: '\Drupal\form_test\Form\FormTestMachineNameForm'
|
||||
_title: 'Machine name fields'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
form_test.state_persistence:
|
||||
path: '/form-test/state-persist'
|
||||
defaults:
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\form_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
/**
|
||||
* Form constructor for testing #type 'machine_name' elements.
|
||||
*/
|
||||
class FormTestMachineNameForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'form_test_machine_name';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['machine_name_1_label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Machine name 1 label',
|
||||
];
|
||||
$form['machine_name_1'] = [
|
||||
'#type' => 'machine_name',
|
||||
'#title' => 'Machine name 1',
|
||||
'#description' => 'A machine name.',
|
||||
'#machine_name' => [
|
||||
'source' => ['machine_name_1_label']
|
||||
],
|
||||
];
|
||||
$form['machine_name_2_label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Machine name 2 label',
|
||||
];
|
||||
$form['machine_name_2'] = [
|
||||
'#type' => 'machine_name',
|
||||
'#title' => 'Machine name 2',
|
||||
'#description' => 'Another machine name.',
|
||||
'#machine_name' => [
|
||||
'source' => ['machine_name_2_label']
|
||||
],
|
||||
];
|
||||
$form['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => 'Submit',
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_state->setResponse(new JsonResponse($form_state->getValues()));
|
||||
}
|
||||
|
||||
}
|
|
@ -3,3 +3,7 @@
|
|||
<div>link via the linkgenerator: {{ link('register', test_url_attribute, {'id': 'kitten'}) }}</div>
|
||||
<div>link via the linkgenerator: {{ link('register', 'route:user.register', {'id': 'kitten'}) }}</div>
|
||||
<div>link via the linkgenerator: {{ link('register', 'route:user.register', attributes) }}</div>
|
||||
{% set title %}<span>register</span>{% endset %}
|
||||
<div>link via the linkgenerator: {{ link(title, test_url) }}</div>
|
||||
{% set title %}<span>register</span><svg></svg>{% endset %}
|
||||
<div>link via the linkgenerator: {{ link(title, test_url) }}</div>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Kernel\Form;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||
|
||||
/**
|
||||
* Tests for form_element_label theme hook.
|
||||
*
|
||||
* @group Form
|
||||
*/
|
||||
class FormElementLabelTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Ensures that attributes can be placed for form element label.
|
||||
*/
|
||||
public function testAttributes() {
|
||||
$render_array = [
|
||||
'#type' => 'label',
|
||||
'#attributes' => ['class' => ['kitten']],
|
||||
'#title' => 'Kittens',
|
||||
'#title_display' => 'above',
|
||||
];
|
||||
$css_selector_converter = new CssSelectorConverter();
|
||||
$this->render($render_array);
|
||||
$elements = $this->xpath($css_selector_converter->toXPath('.kitten'));
|
||||
$this->assertCount(1, $elements);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Kernel\Installer;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests that we handle the absence of a module dependency during install.
|
||||
*
|
||||
* @group Installer
|
||||
*/
|
||||
class InstallerMissingDependenciesTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Verifies that the exception message in the profile step is correct.
|
||||
*/
|
||||
public function testSetUpWithMissingDependencies() {
|
||||
// Prime the drupal_get_filename() static cache with the location of the
|
||||
// testing profile as it is not the currently active profile and we don't
|
||||
// yet have any cached way to retrieve its location.
|
||||
// @todo Remove as part of https://www.drupal.org/node/2186491
|
||||
drupal_get_filename('profile', 'testing_missing_dependencies', 'core/profiles/testing_missing_dependencies/testing_missing_dependencies.info.yml');
|
||||
|
||||
$info = drupal_verify_profile([
|
||||
'parameters' => ['profile' => 'testing_missing_dependencies'],
|
||||
'profile_info' => install_profile_info('testing_missing_dependencies'),
|
||||
]);
|
||||
|
||||
$message = $info['required_modules']['description']->render();
|
||||
$this->assertContains('Missing_module1', $message);
|
||||
$this->assertContains('Missing_module2', $message);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Kernel\Migrate;
|
||||
namespace Drupal\Tests\system\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
@ -18,7 +18,7 @@ class MigrateMenuTest extends MigrateDrupal6TestBase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('menu');
|
||||
$this->executeMigration('d6_menu');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,12 +26,12 @@ class MigrateMenuTest extends MigrateDrupal6TestBase {
|
|||
*/
|
||||
public function testMenu() {
|
||||
$navigation_menu = Menu::load('navigation');
|
||||
$this->assertIdentical('navigation', $navigation_menu->id());
|
||||
$this->assertIdentical('Navigation', $navigation_menu->label());
|
||||
$this->assertSame('navigation', $navigation_menu->id());
|
||||
$this->assertSame('Navigation', $navigation_menu->label());
|
||||
$expected = <<<EOT
|
||||
The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.
|
||||
EOT;
|
||||
$this->assertIdentical($expected, $navigation_menu->getDescription());
|
||||
$this->assertSame($expected, $navigation_menu->getDescription());
|
||||
|
||||
// Test that we can re-import using the ConfigEntityBase destination.
|
||||
Database::getConnection('default', 'migrate')
|
||||
|
@ -40,14 +40,14 @@ EOT;
|
|||
->condition('menu_name', 'navigation')
|
||||
->execute();
|
||||
|
||||
$migration = $this->getMigration('menu');
|
||||
$migration = $this->getMigration('d6_menu');
|
||||
\Drupal::database()
|
||||
->truncate($migration->getIdMap()->mapTableName())
|
||||
->execute();
|
||||
$this->executeMigration($migration);
|
||||
|
||||
$navigation_menu = Menu::load('navigation');
|
||||
$this->assertIdentical('Home Navigation', $navigation_menu->label());
|
||||
$this->assertSame('Home Navigation', $navigation_menu->label());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
use Drupal\system\Entity\Menu;
|
||||
|
||||
/**
|
||||
* Upgrade menus to system.menu.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateMenuTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts various aspects of a menu.
|
||||
*
|
||||
* @param $id
|
||||
* The menu ID.
|
||||
* @param $label
|
||||
* The menu label.
|
||||
* @param $description
|
||||
* The menu description.
|
||||
*/
|
||||
protected function assertEntity($id, $label, $description) {
|
||||
$navigation_menu = Menu::load($id);
|
||||
$this->assertSame($id, $navigation_menu->id());
|
||||
$this->assertSame($label, $navigation_menu->label());
|
||||
$this->assertSame($description, $navigation_menu->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 7 menu to Drupal 8 migration.
|
||||
*/
|
||||
public function testMenu() {
|
||||
$this->assertEntity('main', 'Main menu', 'The <em>Main</em> menu is used on many sites to show the major sections of the site, often in a top navigation bar.');
|
||||
$this->assertEntity('admin', 'Management', 'The <em>Management</em> menu contains links for administrative tasks.');
|
||||
$this->assertEntity('menu-test-menu', 'Test Menu', 'Test menu description.');
|
||||
$this->assertEntity('tools', 'Navigation', 'The <em>Navigation</em> menu contains links intended for site visitors. Links are added to the <em>Navigation</em> menu automatically by some modules.');
|
||||
$this->assertEntity('account', 'User menu', 'The <em>User</em> menu contains links related to the user\'s account, as well as the \'Log out\' link.');
|
||||
|
||||
// Test that we can re-import using the ConfigEntityBase destination.
|
||||
Database::getConnection('default', 'migrate')
|
||||
->update('menu_custom')
|
||||
->fields(array('title' => 'Home Navigation'))
|
||||
->condition('menu_name', 'navigation')
|
||||
->execute();
|
||||
|
||||
$migration = $this->getMigration('d7_menu');
|
||||
\Drupal::database()
|
||||
->truncate($migration->getIdMap()->mapTableName())
|
||||
->execute();
|
||||
$this->executeMigration($migration);
|
||||
|
||||
$navigation_menu = Menu::load('tools');
|
||||
$this->assertSame('Home Navigation', $navigation_menu->label());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Kernel\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests menu source plugin.
|
||||
*
|
||||
* @covers Drupal\system\Plugin\migrate\source\Menu
|
||||
*
|
||||
* @group system
|
||||
*/
|
||||
class MenuTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['menu_custom'] = [
|
||||
[
|
||||
'menu_name' => 'menu-name-1',
|
||||
'title' => 'menu custom value 1',
|
||||
'description' => 'menu custom description value 1',
|
||||
],
|
||||
[
|
||||
'menu_name' => 'menu-name-2',
|
||||
'title' => 'menu custom value 2',
|
||||
'description' => 'menu custom description value 2',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results are identical to the source data.
|
||||
$tests[0]['expected_data'] = $tests[0]['source_data']['menu_custom'];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\system\Unit\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests menu source plugin.
|
||||
*
|
||||
* @group system
|
||||
*/
|
||||
class MenuTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\system\Plugin\migrate\source\Menu';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'menu',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'menu_name' => 'menu-name-1',
|
||||
'title' => 'menu custom value 1',
|
||||
'description' => 'menu custom description value 1',
|
||||
),
|
||||
array(
|
||||
'menu_name' => 'menu-name-2',
|
||||
'title' => 'menu custom value 2',
|
||||
'description' => 'menu custom description value 2',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['menu_custom'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue