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

This commit is contained in:
Pantheon Automation 2016-03-02 12:40:24 -08:00 committed by Greg Anderson
parent 2a9f1f148d
commit fd3b12cf27
251 changed files with 5439 additions and 957 deletions

View file

@ -5,6 +5,7 @@
* Post update functions for Field module.
*/
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
@ -44,3 +45,34 @@ function field_post_update_entity_reference_handler_setting() {
/**
* @} End of "addtogroup updates-8.0.0-beta".
*/
/**
* @addtogroup updates-8.1.0
* @{
*/
/**
* Adds the 'size' setting for email widgets.
*/
function field_post_update_email_widget_size_setting() {
foreach (EntityFormDisplay::loadMultiple() as $entity_form_display) {
$changed = FALSE;
foreach ($entity_form_display->getComponents() as $name => $options) {
if (isset($options['type']) && $options['type'] === 'email_default') {
$options['settings']['size'] = '60';
$entity_form_display->setComponent($name, $options);
$changed = TRUE;
}
}
if ($changed) {
$entity_form_display->save();
}
}
return t('The new size setting for email widgets has been added.');
}
/**
* @} End of "addtogroup updates-8.1.0".
*/

View file

@ -51,14 +51,16 @@ class FieldInstanceSettings extends ProcessPluginBase {
case 'imagefield_widget':
$settings['file_extensions'] = $widget_settings['file_extensions'];
$settings['file_directory'] = 'public://';
$settings['file_directory'] = $widget_settings['file_path'];
$settings['max_filesize'] = $this->convertSizeUnit($widget_settings['max_filesize_per_file']);
$settings['alt_field'] = $widget_settings['alt'];
$settings['alt_field_required'] = $widget_settings['custom_alt'];
$settings['title_field'] = $widget_settings['title'];
$settings['title_field_required'] = $widget_settings['custom_title'];
$settings['max_resolution'] = $widget_settings['max_resolution'];
$settings['min_resolution'] = $widget_settings['min_resolution'];
// With nothing entered for min or max resolution in Drupal 6, zero is
// stored. For Drupal 8 this should be an empty string.
$settings['max_resolution'] = !empty($widget_settings['max_resolution']) ? $widget_settings['max_resolution'] : '';
$settings['min_resolution'] = !empty($widget_settings['min_resolution']) ? $widget_settings['min_resolution'] : '';
break;
}

View file

@ -62,6 +62,16 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
$this->assertIdentical('Email Field', $field->label());
$this->assertIdentical('benjy@example.com', $entity->field_test_email->value);
// Test image field.
$field = FieldConfig::load('node.story.field_test_imagefield');
$this->assertIdentical('Image Field', $field->label());
$field_settings = $field->getSettings();
$this->assertIdentical('', $field_settings['max_resolution']);
$this->assertIdentical('', $field_settings['min_resolution']);
$this->assertIdentical('', $field_settings['file_directory']);
$this->assertIdentical('png gif jpg jpeg', $field_settings['file_extensions']);
$this->assertIdentical('public', $field_settings['uri_scheme']);
// Test a filefield.
$field = FieldConfig::load('node.story.field_test_filefield');
$this->assertIdentical('File Field', $field->label());

View file

@ -56,6 +56,7 @@ class MigrateFieldWidgetSettingsTest extends MigrateDrupal6TestBase {
$component = $form_display->getComponent('field_test_email');
$expected['type'] = 'email_default';
$expected['weight'] = 6;
$expected['settings'] = array('placeholder' => '', 'size' => 60);
$this->assertIdentical($expected, $component);
// Link field.

View file

@ -0,0 +1,53 @@
<?php
/**
* @file
* Contains \Drupal\field\Tests\Update\EmailWidgetSizeSettingUpdateTest.
*/
namespace Drupal\field\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
/**
* Tests the update for the 'size' setting of the 'email_default' field widget.
*
* @group field
*/
class EmailWidgetSizeSettingUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../tests/fixtures/update/drupal-8.email_widget_size_setting-2578741.php',
];
}
/**
* Tests field_post_update_email_widget_size_setting().
*
* @see field_post_update_email_widget_size_setting()
*/
public function testFieldPostUpdateEmailWidgetSizeSetting() {
$configFactory = $this->container->get('config.factory');
// Load the 'node.article.default' entity form display and check that the
// widget for 'field_email_2578741' does not have a 'size' setting.
/** @var \Drupal\Core\Config\Config $config */
$config = $configFactory->get('core.entity_form_display.node.article.default');
$settings = $config->get('content.field_email_2578741.settings');
$this->assertTrue(!isset($settings['size']), 'The size setting does not exist prior to running the update functions.');
// Run updates.
$this->runUpdates();
// Reload the config and check that the 'size' setting has been populated.
$config = $configFactory->get('core.entity_form_display.node.article.default');
$settings = $config->get('content.field_email_2578741.settings');
$this->assertEqual($settings['size'], 60, 'The size setting exists and it has the correct default value.');
}
}

View file

@ -7,6 +7,8 @@
namespace Drupal\field\Tests\Views;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\views\Views;
/**
@ -112,4 +114,32 @@ class FieldUITest extends FieldTestBase {
$this->assertEqual($options, array('format', 'value'), 'The expected sort field options were found.');
}
/**
* Tests adding a boolean field filter handler.
*/
public function testBooleanFilterHandler() {
// Create a boolean field.
$field_name = 'field_boolean';
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'boolean',
]);
$field_storage->save();
$field = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'page',
]);
$field->save();
$url = "admin/structure/views/nojs/add-handler/test_view_fieldapi/default/filter";
$this->drupalPostForm($url, ['name[node__' . $field_name . '.' . $field_name . '_value]' => TRUE], t('Add and configure @handler', array('@handler' => t('filter criteria'))));
$this->assertResponse(200);
// Verify that using a boolean field as a filter also results in using the
// boolean plugin.
$option = $this->xpath('//label[@for="edit-options-value-1"]');
$this->assertEqual(t('True'), (string) $option[0]);
$option = $this->xpath('//label[@for="edit-options-value-0"]');
$this->assertEqual(t('False'), (string) $option[0]);
}
}

View file

@ -0,0 +1,37 @@
<?php
/**
* @file
* Contains SQL necessary to add a new component for an email field/widget to
* the 'node.article.default' entity form display.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
$config = $connection->select('config', 'c')
->fields('c')
->condition('collection', '')
->condition('name', 'core.entity_form_display.node.article.default')
->execute()
->fetchAssoc();
$data = unserialize($config['data']);
// Manually add a new component that simulates an email field using the default
// email widget.
$data['content']['field_email_2578741'] = [
'weight' => 20,
'settings' => [
'placeholder' => '',
],
'third_party_settings' => [],
'type' => 'email_default',
];
$connection->update('config')
->fields(['data' => serialize($data)])
->condition('collection', '')
->condition('name', 'core.entity_form_display.node.article.default')
->execute();

View file

@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\process\d7\FieldInstanceSettingsTest.
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\process\d7\FieldSettingsTest.
*/
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d7;