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
+1 -1
View File
@@ -5,4 +5,4 @@ core: 8.x
package: Field types
version: VERSION
dependencies:
- field
- drupal:field
@@ -32,7 +32,7 @@ class LinkItem extends FieldItemBase implements LinkItemInterface {
public static function defaultFieldSettings() {
return [
'title' => DRUPAL_OPTIONAL,
'link_type' => LinkItemInterface::LINK_GENERIC
'link_type' => LinkItemInterface::LINK_GENERIC,
] + parent::defaultFieldSettings();
}
@@ -101,7 +101,7 @@ class LinkWidget extends WidgetBase {
*/
protected static function getUserEnteredStringAsUri($string) {
// By default, assume the entered string is an URI.
$uri = $string;
$uri = trim($string);
// Detect entity autocomplete string, map to 'entity:' URI.
$entity_id = EntityAutocomplete::extractEntityIdFromAutocompleteInput($string);
@@ -157,6 +157,17 @@ class LinkWidget extends WidgetBase {
}
}
/**
* Form element validation handler for the 'title' element.
*
* Requires the URL value if a link title was filled in.
*/
public static function validateTitleNoLink(&$element, FormStateInterface $form_state, $form) {
if ($element['uri']['#value'] === '' && $element['title']['#value'] !== '') {
$form_state->setError($element['uri'], t('The @uri field is required when the @title field is specified.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
}
}
/**
* {@inheritdoc}
*/
@@ -222,8 +233,12 @@ class LinkWidget extends WidgetBase {
// Post-process the title field to make it conditionally required if URL is
// non-empty. Omit the validation on the field edit form, since the field
// settings cannot be saved otherwise.
//
// Validate that title field is filled out (regardless of uri) when it is a
// required field.
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') === DRUPAL_REQUIRED) {
$element['#element_validate'][] = [get_called_class(), 'validateTitleElement'];
$element['#element_validate'][] = [get_called_class(), 'validateTitleNoLink'];
if (!$element['title']['#required']) {
// Make title required on the front-end when URI filled-in.
@@ -237,11 +252,17 @@ class LinkWidget extends WidgetBase {
}
$element['title']['#states']['required'] = [
':input[name="' . $selector . '[' . $delta . '][uri]"]' => ['filled' => TRUE]
':input[name="' . $selector . '[' . $delta . '][uri]"]' => ['filled' => TRUE],
];
}
}
// Ensure that a URI is always entered when an optional title field is
// submitted.
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') == DRUPAL_OPTIONAL) {
$element['#element_validate'][] = [get_called_class(), 'validateTitleNoLink'];
}
// Exposing the attributes array in the widget is left for alternate and more
// advanced field widgets.
$element['attributes'] = [
@@ -377,7 +398,6 @@ class LinkWidget extends WidgetBase {
return $values;
}
/**
* {@inheritdoc}
*
@@ -30,7 +30,7 @@ class LinkNotExistingInternalConstraintValidator extends ConstraintValidator {
if ($url->isRouted()) {
$allowed = TRUE;
try {
$url->toString();
$url->toString(TRUE);
}
// The following exceptions are all possible during URL generation, and
// should be considered as disallowed URLs.
@@ -29,8 +29,8 @@ class LinkField extends CckFieldPluginBase {
* {@inheritdoc}
*/
public function getFieldFormatterMap() {
// See d6_field_formatter_settings.yml and CckFieldPluginBase
// processFieldFormatter().
// See d6_field_formatter_settings.yml and FieldPluginBase
// alterFieldFormatterMigration().
return [
'default' => 'link',
'plain' => 'link',
@@ -38,9 +38,9 @@ class LinkField extends D6LinkField {
}
/**
* {@inheritdoc}
* @inheritdoc}
*/
public function processFieldInstance(MigrationInterface $migration) {
public function alterFieldInstanceMigration(MigrationInterface $migration) {
$process = [
'plugin' => 'static_map',
'source' => 'settings/title',
@@ -23,7 +23,7 @@ class LinkField extends FieldPluginBase {
*/
public function getFieldFormatterMap() {
// See d6_field_formatter_settings.yml and FieldPluginBase
// processFieldFormatter().
// alterFieldFormatterMigration().
return [
'default' => 'link',
'plain' => 'link',
@@ -39,7 +39,7 @@ class LinkField extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
$process = [
'plugin' => 'field_link',
'source' => $field_name,
@@ -42,7 +42,7 @@ class LinkField extends D6LinkField {
/**
* {@inheritdoc}
*/
public function processFieldInstance(MigrationInterface $migration) {
public function alterFieldInstanceMigration(MigrationInterface $migration) {
$process = [
'plugin' => 'static_map',
'source' => 'settings/title',
@@ -45,7 +45,7 @@ class LinkViewsTokensTest extends ViewTestBase {
// Create Basic page node type.
$this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page'
'name' => 'Basic page',
]);
// Create a field.
@@ -4,5 +4,5 @@ type: module
core: 8.x
hidden: true
dependencies:
- link
- entity_test
- drupal:link
- drupal:entity_test
@@ -5,6 +5,6 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- node
- views
- link
- drupal:node
- drupal:views
- drupal:link
@@ -59,7 +59,7 @@ class LinkFieldTest extends BrowserTestBase {
* Tests link field URL validation.
*/
public function testURLValidation() {
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
@@ -121,6 +121,10 @@ class LinkFieldTest extends BrowserTestBase {
'/?example=llama' => '<front>?example=llama',
'/#example' => '<front>#example',
// Trailing spaces should be ignored.
'/ ' => '<front>',
'/path with spaces ' => '/path with spaces',
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
'<front>' => '&lt;front&gt;',
@@ -200,7 +204,7 @@ class LinkFieldTest extends BrowserTestBase {
preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertRaw($string);
$this->assertRaw('"' . $string . '"');
}
}
@@ -226,7 +230,7 @@ class LinkFieldTest extends BrowserTestBase {
* Tests the link title settings of a link field.
*/
public function testLinkTitle() {
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
@@ -281,6 +285,14 @@ class LinkFieldTest extends BrowserTestBase {
$this->assertRaw('placeholder="Enter the text for this link"');
$this->assertFieldByName("{$field_name}[0][title]", '', 'Link text field found.');
if ($title_setting === DRUPAL_OPTIONAL) {
// Verify that the URL is required, if the link text is non-empty.
$edit = [
"{$field_name}[0][title]" => 'Example',
];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('The URL field is required when the @title field is specified.', ['@title' => t('Link text')]));
}
if ($title_setting === DRUPAL_REQUIRED) {
// Verify that the link text is required, if the URL is non-empty.
$edit = [
@@ -340,7 +352,7 @@ class LinkFieldTest extends BrowserTestBase {
* Tests the default 'link' formatter.
*/
public function testLinkFormatter() {
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
@@ -495,7 +507,7 @@ class LinkFieldTest extends BrowserTestBase {
* merged, since they involve different configuration and output.
*/
public function testLinkSeparateFormatter() {
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
'field_name' => $field_name,
@@ -622,7 +634,7 @@ class LinkFieldTest extends BrowserTestBase {
public function testLinkTypeOnLinkWidget() {
$link_type = LinkItemInterface::LINK_EXTERNAL;
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
// Create a field with settings to validate.
$this->fieldStorage = FieldStorageConfig::create([
@@ -654,7 +666,6 @@ class LinkFieldTest extends BrowserTestBase {
$this->assertEqual($form[$field_name]['widget'][0]['uri']['#link_type'], $link_type);
}
/**
* Tests editing a link to a non-node entity.
*/
@@ -0,0 +1,83 @@
<?php
namespace Drupal\Tests\link\Kernel;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\link\LinkItemInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Tests\field\Kernel\FieldKernelTestBase;
/**
* Tests link field serialization.
*
* @group link
*/
class LinkItemSerializationTest extends FieldKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['link', 'serialization'];
/**
* The serializer service.
*
* @var \Symfony\Component\Serializer\SerializerInterface
*/
protected $serializer;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('user');
$this->serializer = \Drupal::service('serializer');
// Create a generic, external, and internal link fields for validation.
FieldStorageConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test',
'type' => 'link',
])->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_test',
'bundle' => 'entity_test',
'settings' => ['link_type' => LinkItemInterface::LINK_GENERIC],
])->save();
}
/**
* Tests the serialization.
*/
public function testLinkSerialization() {
// Create entity.
$entity = EntityTest::create();
$url = 'https://www.drupal.org?test_param=test_value';
$parsed_url = UrlHelper::parse($url);
$title = $this->randomMachineName();
$class = $this->randomMachineName();
$entity->field_test->uri = $parsed_url['path'];
$entity->field_test->title = $title;
$entity->field_test->first()
->get('options')
->set('query', $parsed_url['query']);
$entity->field_test->first()
->get('options')
->set('attributes', ['class' => $class]);
$entity->save();
$serialized = $this->serializer->serialize($entity, 'json');
$deserialized = $this->serializer->deserialize($serialized, EntityTest::class, 'json');
$options_expected = [
'query' => $parsed_url['query'],
'attributes' => ['class' => $class],
];
$this->assertSame($options_expected, $deserialized->field_test->options);
}
}
@@ -0,0 +1,18 @@
<?php
namespace Drupal\Tests\link\Kernel\Plugin\migrate\cckfield\d7;
/**
* @group link
* @group legacy
*/
class LinkCckDeprecationTest extends LinkCckTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldInstanceMigration() instead. See https://www.drupal.org/node/2944598.
*/
public function testAlterFieldInstanceMigration($method = 'processFieldInstance') {
parent::testAlterFieldInstanceMigration($method);
}
}
@@ -39,7 +39,7 @@ class LinkCckTest extends KernelTestBase {
$migration = $this->prophesize(MigrationInterface::class);
// The plugin's processFieldInstance() method will call
// The plugin's alterFieldInstanceMigration() method will call
// mergeProcessOfProperty() 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 mergeProcessOfProperty().
@@ -52,12 +52,10 @@ class LinkCckTest extends KernelTestBase {
}
/**
* @covers ::processCckFieldValues
* @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
* @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.
* @covers ::alterFieldInstanceMigration
*/
public function testProcessCckFieldValues() {
$this->plugin->processFieldInstance($this->migration);
public function testAlterFieldInstanceMigration($method = 'alterFieldInstanceMigration') {
$this->plugin->$method($this->migration);
$expected = [
'plugin' => 'static_map',
@@ -0,0 +1,18 @@
<?php
namespace Drupal\Tests\link\Kernel\Plugin\migrate\field\d7;
/**
* @group legacy
* @group link
*/
class LinkFieldLegacyTest extends LinkFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldInstanceMigration() instead. See https://www.drupal.org/node/2944598.
*/
public function testAlterFieldInstanceMigration($method = 'processFieldInstance') {
parent::testAlterFieldInstanceMigration($method);
}
}
@@ -38,7 +38,7 @@ class LinkFieldTest extends KernelTestBase {
$migration = $this->prophesize(MigrationInterface::class);
// The plugin's ProcessFieldInstance() method will call
// The plugin's alterFieldInstanceMigration() method will call
// mergeProcessOfProperty() 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 mergeProcessOfProperty().
@@ -51,10 +51,10 @@ class LinkFieldTest extends KernelTestBase {
}
/**
* @covers ::processFieldInstance
* @covers ::alterFieldInstanceMigration
*/
public function testProcessFieldInstance() {
$this->plugin->processFieldInstance($this->migration);
public function testAlterFieldInstanceMigration($method = 'alterFieldInstanceMigration') {
$this->plugin->$method($this->migration);
$expected = [
'plugin' => 'static_map',
@@ -0,0 +1,18 @@
<?php
namespace Drupal\Tests\link\Unit\Plugin\migrate\field\d6;
/**
* @group legacy
* @group link
*/
class LinkFieldLegacyTest extends LinkFieldTest {
/**
* @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 testDefineValueProcessPipeline($method = 'processFieldValues') {
parent::testDefineValueProcessPipeline($method);
}
}
@@ -31,7 +31,7 @@ class LinkFieldTest extends UnitTestCase {
$migration = $this->prophesize(MigrationInterface::class);
// The plugin's processFieldValues() method will call
// The plugin's defineValueProcessPipeline() method will call
// mergeProcessOfProperty() 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 mergeProcessOfProperty().
@@ -44,10 +44,10 @@ class LinkFieldTest extends UnitTestCase {
}
/**
* @covers ::processFieldValues
* @covers ::defineValueProcessPipeline
*/
public function testProcessFieldValues() {
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') {
$this->plugin->$method($this->migration, 'somefieldname', []);
$expected = [
'plugin' => 'field_link',