updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
@@ -62,7 +62,7 @@ class TextItem extends TextItemBase {
'Length' => [
'max' => $max_length,
'maxMessage' => t('%name: the text may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
]
],
],
]);
}
@@ -44,7 +44,7 @@ class TextField extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function processFieldValues(MigrationInterface $migration, $field_name, $field_info) {
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $field_info) {
$widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type'];
if ($widget_type == 'optionwidgets_onoff') {
@@ -1,13 +1,14 @@
<?php
namespace Drupal\text\Tests;
namespace Drupal\Tests\text\Functional;
use Drupal\Component\Utility\Unicode;
use Drupal\Component\Utility\Html;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\String\StringFieldTest;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\filter\Entity\FilterFormat;
use Drupal\Tests\field\Functional\String\StringFieldTest;
use Drupal\Tests\TestFileCreationTrait;
/**
* Tests the creation of text fields.
@@ -16,6 +17,10 @@ use Drupal\filter\Entity\FilterFormat;
*/
class TextFieldTest extends StringFieldTest {
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
/**
* A user with relevant administrative privileges.
*
@@ -37,14 +42,14 @@ class TextFieldTest extends StringFieldTest {
public function testTextFieldValidation() {
// Create a field with settings to validate.
$max_length = 3;
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text',
'settings' => [
'max_length' => $max_length,
]
],
]);
$field_storage->save();
FieldConfig::create([
@@ -90,7 +95,7 @@ class TextFieldTest extends StringFieldTest {
$field_storage = FieldStorageConfig::create([
'field_name' => $file_field_name,
'entity_type' => 'entity_test',
'type' => 'file'
'type' => 'file',
]);
$field_storage->save();
FieldConfig::create([
@@ -117,7 +122,7 @@ class TextFieldTest extends StringFieldTest {
$this->drupalPostForm('entity_test/add', $edit, 'Upload');
$this->assertResponse(200);
$edit = [
'text_long[0][value]' => 'Long text'
'text_long[0][value]' => 'Long text',
];
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertResponse(200);
@@ -149,11 +154,11 @@ class TextFieldTest extends StringFieldTest {
$renderer = $this->container->get('renderer');
// Create a field.
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => $field_type
'type' => $field_type,
]);
$field_storage->save();
FieldConfig::create([
@@ -191,7 +196,7 @@ class TextFieldTest extends StringFieldTest {
"{$field_name}[0][value]" => $value,
];
$this->drupalPostForm(NULL, $edit, t('Save'));
preg_match('|entity_test/manage/(\d+)|', $this->url, $match);
preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]), 'Entity was created');
@@ -199,15 +204,15 @@ class TextFieldTest extends StringFieldTest {
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent($renderer->renderRoot($content));
$this->assertNoRaw($value, 'HTML tags are not displayed.');
$this->assertEscaped($value, 'Escaped HTML is displayed correctly.');
$rendered_entity = \Drupal::service('renderer')->renderRoot($content);
$this->assertNotContains($value, (string) $rendered_entity);
$this->assertContains(Html::escape($value), (string) $rendered_entity);
// Create a new text format that does not escape HTML, and grant the user
// access to it.
$this->drupalLogin($this->adminUser);
$edit = [
'format' => Unicode::strtolower($this->randomMachineName()),
'format' => mb_strtolower($this->randomMachineName()),
'name' => $this->randomMachineName(),
];
$this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration'));
@@ -238,8 +243,8 @@ class TextFieldTest extends StringFieldTest {
$entity = EntityTest::load($id);
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
$content = $display->build($entity);
$this->setRawContent($renderer->renderRoot($content));
$this->assertRaw($value, 'Value is displayed unfiltered');
$rendered_entity = \Drupal::service('renderer')->renderRoot($content);
$this->assertContains($value, (string) $rendered_entity);
}
}
@@ -0,0 +1,85 @@
<?php
namespace Drupal\Tests\text\FunctionalJavascript;
use Drupal\field\Entity\FieldConfig;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Tests the JavaScript functionality of the text_textarea_with_summary widget.
*
* @group text
*/
class TextareaWithSummaryTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['text', 'node'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(['type' => 'page']);
$account = $this->drupalCreateUser(['create page content', 'edit own page content']);
$this->drupalLogin($account);
}
/**
* Helper to test toggling the summary area.
*/
protected function assertSummaryToggle() {
$this->drupalGet('node/add/page');
$widget = $this->getSession()->getPage()->findById('edit-body-wrapper');
$summary_field = $widget->findField('edit-body-0-summary');
$this->assertEquals(FALSE, $summary_field->isVisible(), 'Summary field is hidden by default.');
$this->assertEquals(FALSE, $widget->hasButton('Hide summary'), 'No Hide summary link by default.');
$widget->pressButton('Edit summary');
$this->assertEquals(FALSE, $widget->hasButton('Edit summary'), 'Edit summary link is removed after clicking.');
$this->assertEquals(TRUE, $summary_field->isVisible(), 'Summary field is shown.');
$widget->pressButton('Hide summary');
$this->assertEquals(FALSE, $widget->hasButton('Hide summary'), 'Hide summary link is removed after clicking.');
$this->assertEquals(FALSE, $summary_field->isVisible(), 'Summary field is hidden again.');
$this->assertEquals(TRUE, $widget->hasButton('Edit summary'), 'Edit summary link is visible again.');
}
/**
* Tests the textSummary javascript behavior.
*/
public function testTextSummaryBehavior() {
// Test with field defaults.
$this->assertSummaryToggle();
// Repeat test with non-empty field description.
$body_field = FieldConfig::loadByName('node', 'page', 'body');
$body_field->set('description', 'Text with Summary field description.');
$body_field->save();
$this->assertSummaryToggle();
// Test summary is shown when non-empty.
$node = $this->createNode([
'body' => [
[
'value' => $this->randomMachineName(32),
'summary' => $this->randomMachineName(32),
'format' => filter_default_format(),
],
],
]);
$this->drupalGet('node/' . $node->id() . '/edit');
$page = $this->getSession()->getPage();
$summary_field = $page->findField('edit-body-0-summary');
$this->assertEquals(TRUE, $summary_field->isVisible(), 'Non-empty summary field is shown by default.');
}
}
@@ -26,7 +26,7 @@ class TextWithSummaryItemTest extends FieldKernelTestBase {
/**
* Field storage entity.
*
* @var \Drupal\field\Entity\FieldStorageConfig.
* @var \Drupal\field\Entity\FieldStorageConfig
*/
protected $fieldStorage;
@@ -37,7 +37,6 @@ class TextWithSummaryItemTest extends FieldKernelTestBase {
*/
protected $field;
protected function setUp() {
parent::setUp();
@@ -106,7 +105,7 @@ class TextWithSummaryItemTest extends FieldKernelTestBase {
'type' => 'text_with_summary',
'settings' => [
'max_length' => 10,
]
],
]);
$this->fieldStorage->save();
$this->field = FieldConfig::create([
@@ -76,7 +76,7 @@ class TextCckTest extends UnitTestCase {
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo\nbar",
]
],
];
$this->plugin->processCckFieldValues($this->migration, 'field', $info);
@@ -101,7 +101,7 @@ class TextCckTest extends UnitTestCase {
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo|Foo\nbaz|Baz",
]
],
];
$this->plugin->processCckFieldValues($this->migration, 'field', $info);
@@ -33,7 +33,7 @@ class TextFieldTest extends UnitTestCase {
$migration = $this->prophesize(MigrationInterface::class);
// The plugin's processFieldValues() method will call
// The plugin's defineValueProcessPipeline() method will call
// setProcessOfProperty() and return nothing. So, in order to examine the
// process pipeline created by the plugin, we need to ensure that
// getProcess() always returns the last input to setProcessOfProperty().
@@ -46,7 +46,11 @@ class TextFieldTest extends UnitTestCase {
}
/**
* Calls the deprecated processFieldValues() method to test BC.
*
* @covers ::processFieldValues
*
* @depends testFilteredTextValueProcessPipeline
*/
public function testProcessFilteredTextFieldValues() {
$field_info = [
@@ -69,14 +73,41 @@ class TextFieldTest extends UnitTestCase {
}
/**
* @covers ::defineValueProcessPipeline
*/
public function testFilteredTextValueProcessPipeline() {
$field_info = [
'widget_type' => 'text_textfield',
];
$this->plugin->defineValueProcessPipeline($this->migration, 'body', $field_info);
$process = $this->migration->getProcess();
$this->assertSame('sub_process', $process['plugin']);
$this->assertSame('body', $process['source']);
$this->assertSame('value', $process['process']['value']);
// Ensure that filter format IDs will be looked up in the filter format
// migrations.
$lookup = $process['process']['format'][2];
$this->assertSame('migration', $lookup['plugin']);
$this->assertContains('d6_filter_format', $lookup['migration']);
$this->assertContains('d7_filter_format', $lookup['migration']);
$this->assertSame('format', $lookup['source']);
}
/**
* Calls the deprecated processFieldValues() method to test BC.
*
* @covers ::processFieldValues
*
* @depends testBooleanTextImplicitValueProcessPipeline
*/
public function testProcessBooleanTextImplicitValues() {
$info = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo\nbar",
]
],
];
$this->plugin->processFieldValues($this->migration, 'field', $info);
@@ -94,14 +125,43 @@ class TextFieldTest extends UnitTestCase {
}
/**
* @covers ::defineValueProcessPipeline
*/
public function testBooleanTextImplicitValueProcessPipeline() {
$info = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo\nbar",
],
];
$this->plugin->defineValueProcessPipeline($this->migration, 'field', $info);
$expected = [
'value' => [
'plugin' => 'static_map',
'source' => 'value',
'default_value' => 0,
'map' => [
'bar' => 1,
],
],
];
$this->assertSame($expected, $this->migration->getProcess()['process']);
}
/**
* Calls the deprecated processFieldValues() method to test BC.
*
* @covers ::processFieldValues
*
* @depends testBooleanTextExplicitValueProcessPipeline
*/
public function testProcessBooleanTextExplicitValues() {
$info = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo|Foo\nbaz|Baz",
]
],
];
$this->plugin->processFieldValues($this->migration, 'field', $info);
@@ -118,6 +178,31 @@ class TextFieldTest extends UnitTestCase {
$this->assertSame($expected, $this->migration->getProcess()['process']);
}
/**
* @covers ::defineValueProcessPipeline
*/
public function testBooleanTextExplicitValueProcessPipeline() {
$info = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo|Foo\nbaz|Baz",
],
];
$this->plugin->defineValueProcessPipeline($this->migration, 'field', $info);
$expected = [
'value' => [
'plugin' => 'static_map',
'source' => 'value',
'default_value' => 0,
'map' => [
'baz' => 1,
],
],
];
$this->assertSame($expected, $this->migration->getProcess()['process']);
}
/**
* Data provider for testGetFieldType().
*/
@@ -76,7 +76,7 @@ class TextCckTest extends UnitTestCase {
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo\nbar",
]
],
];
$this->plugin->processCckFieldValues($this->migration, 'field', $info);
@@ -101,7 +101,7 @@ class TextCckTest extends UnitTestCase {
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo|Foo\nbaz|Baz",
]
],
];
$this->plugin->processCckFieldValues($this->migration, 'field', $info);
@@ -0,0 +1,36 @@
<?php
namespace Drupal\Tests\text\Unit\Plugin\migrate\field\d6;
/**
* @coversDefaultClass \Drupal\text\Plugin\migrate\field\d6\TextField
* @group text
* @group legacy
*/
class TextFieldLegacyTest extends TextFieldTest {
/**
* @covers ::processFieldValues
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testProcessFilteredTextFieldValues($method = 'processFieldValues') {
parent::testProcessFilteredTextFieldValues($method);
}
/**
* @covers ::processFieldValues
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testProcessBooleanTextImplicitValues($method = 'processFieldValues') {
parent::testProcessBooleanTextImplicitValues($method);
}
/**
* @covers ::processFieldValues
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testProcessBooleanTextExplicitValues($method = 'processFieldValues') {
parent::testProcessBooleanTextExplicitValues($method);
}
}
@@ -32,7 +32,7 @@ class TextFieldTest extends UnitTestCase {
$migration = $this->prophesize(MigrationInterface::class);
// The plugin's processFieldValues() method will call
// The plugin's defineValueProcessPipeline() method will call
// setProcessOfProperty() and return nothing. So, in order to examine the
// process pipeline created by the plugin, we need to ensure that
// getProcess() always returns the last input to setProcessOfProperty().
@@ -45,13 +45,13 @@ class TextFieldTest extends UnitTestCase {
}
/**
* @covers ::processFieldValues
* @covers ::defineValueProcessPipeline
*/
public function testProcessFilteredTextFieldValues() {
public function testProcessFilteredTextFieldValues($method = 'defineValueProcessPipeline') {
$field_info = [
'widget_type' => 'text_textfield',
];
$this->plugin->processFieldValues($this->migration, 'body', $field_info);
$this->plugin->$method($this->migration, 'body', $field_info);
$process = $this->migration->getProcess();
$this->assertSame('sub_process', $process['plugin']);
@@ -68,16 +68,16 @@ class TextFieldTest extends UnitTestCase {
}
/**
* @covers ::processFieldValues
* @covers ::defineValueProcessPipeline
*/
public function testProcessBooleanTextImplicitValues() {
public function testProcessBooleanTextImplicitValues($method = 'defineValueProcessPipeline') {
$info = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo\nbar",
]
],
];
$this->plugin->processFieldValues($this->migration, 'field', $info);
$this->plugin->$method($this->migration, 'field', $info);
$expected = [
'value' => [
@@ -93,16 +93,16 @@ class TextFieldTest extends UnitTestCase {
}
/**
* @covers ::processFieldValues
* @covers ::defineValueProcessPipeline
*/
public function testProcessBooleanTextExplicitValues() {
public function testProcessBooleanTextExplicitValues($method = 'defineValueProcessPipeline') {
$info = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo|Foo\nbaz|Baz",
]
],
];
$this->plugin->processFieldValues($this->migration, 'field', $info);
$this->plugin->$method($this->migration, 'field', $info);
$expected = [
'value' => [
+44 -36
View File
@@ -3,7 +3,7 @@
* Text behaviors.
*/
(function ($, Drupal) {
(function($, Drupal) {
/**
* Auto-hide summary textarea if empty and show hide and unhide links.
*
@@ -14,44 +14,52 @@
*/
Drupal.behaviors.textSummary = {
attach(context, settings) {
$(context).find('.js-text-summary').once('text-summary').each(function () {
const $widget = $(this).closest('.js-text-format-wrapper');
$(context)
.find('.js-text-summary')
.once('text-summary')
.each(function() {
const $widget = $(this).closest('.js-text-format-wrapper');
const $summary = $widget.find('.js-text-summary-wrapper');
const $summaryLabel = $summary.find('label').eq(0);
const $full = $widget.find('.js-text-full').closest('.js-form-item');
let $fullLabel = $full.find('label').eq(0);
const $summary = $widget.find('.js-text-summary-wrapper');
const $summaryLabel = $summary.find('label').eq(0);
const $full = $widget.children('.js-form-type-textarea');
let $fullLabel = $full.find('label').eq(0);
// Create a placeholder label when the field cardinality is greater
// than 1.
if ($fullLabel.length === 0) {
$fullLabel = $('<label></label>').prependTo($full);
}
// Set up the edit/hide summary link.
const $link = $(`<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">${Drupal.t('Hide summary')}</button>)</span>`);
const $button = $link.find('button');
let toggleClick = true;
$link.on('click', (e) => {
if (toggleClick) {
$summary.hide();
$button.html(Drupal.t('Edit summary'));
$link.appendTo($fullLabel);
// Create a placeholder label when the field cardinality is greater
// than 1.
if ($fullLabel.length === 0) {
$fullLabel = $('<label></label>').prependTo($full);
}
else {
$summary.show();
$button.html(Drupal.t('Hide summary'));
$link.appendTo($summaryLabel);
}
e.preventDefault();
toggleClick = !toggleClick;
}).appendTo($summaryLabel);
// If no summary is set, hide the summary field.
if ($widget.find('.js-text-summary').val() === '') {
$link.trigger('click');
}
});
// Set up the edit/hide summary link.
const $link = $(
`<span class="field-edit-link"> (<button type="button" class="link link-edit-summary">${Drupal.t(
'Hide summary',
)}</button>)</span>`,
);
const $button = $link.find('button');
let toggleClick = true;
$link
.on('click', e => {
if (toggleClick) {
$summary.hide();
$button.html(Drupal.t('Edit summary'));
$link.appendTo($fullLabel);
} else {
$summary.show();
$button.html(Drupal.t('Hide summary'));
$link.appendTo($summaryLabel);
}
e.preventDefault();
toggleClick = !toggleClick;
})
.appendTo($summaryLabel);
// If no summary is set, hide the summary field.
if ($widget.find('.js-text-summary').val() === '') {
$link.trigger('click');
}
});
},
};
}(jQuery, Drupal));
})(jQuery, Drupal);
+2 -2
View File
@@ -5,5 +5,5 @@ package: Field types
version: VERSION
core: 8.x
dependencies:
- field
- filter
- drupal:field
- drupal:filter
+1 -1
View File
@@ -13,7 +13,7 @@
var $summary = $widget.find('.js-text-summary-wrapper');
var $summaryLabel = $summary.find('label').eq(0);
var $full = $widget.find('.js-text-full').closest('.js-form-item');
var $full = $widget.children('.js-form-type-textarea');
var $fullLabel = $full.find('label').eq(0);
if ($fullLabel.length === 0) {
+1 -1
View File
@@ -91,7 +91,7 @@ function text_summary($text, $format = NULL, $size = NULL) {
}
// If we have a short body, the entire body is the summary.
if (Unicode::strlen($text) <= $size) {
if (mb_strlen($text) <= $size) {
return $text;
}