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

@ -7,6 +7,7 @@
use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface;
use Drupal\field\ConfigImporterFieldPurger;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\FieldConfigInterface;
@ -168,7 +169,7 @@ function field_cron() {
/**
* Implements hook_entity_field_storage_info().
*/
function field_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) {
function field_entity_field_storage_info(EntityTypeInterface $entity_type) {
if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) {
// Query by filtering on the ID as this is more efficient than filtering
// on the entity_type property directly.
@ -213,7 +214,7 @@ function field_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundl
function field_entity_bundle_delete($entity_type_id, $bundle) {
$storage = \Drupal::entityManager()->getStorage('field_config');
// Get the fields on the bundle.
$fields = $storage->loadByProperties(['entity_type' => $entity_type_id, 'bundle' => $bundle]);
$fields = $storage->loadByProperties(['entity_type' => $entity_type_id, 'bundle' => $bundle]);
// This deletes the data for the field as well as the field themselves. This
// function actually just marks the data and fields as deleted, leaving the
// garbage collection for a separate process, because it is not always
@ -301,7 +302,7 @@ function _field_create_entity_from_ids($ids) {
* Implements hook_config_import_steps_alter().
*/
function field_config_import_steps_alter(&$sync_steps, ConfigImporter $config_importer) {
$field_storages = \Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge(
$field_storages = ConfigImporterFieldPurger::getFieldStoragesToPurge(
$config_importer->getStorageComparer()->getSourceStorage()->read('core.extension'),
$config_importer->getStorageComparer()->getChangelist('delete')
);
@ -327,7 +328,7 @@ function field_form_config_admin_import_form_alter(&$form, FormStateInterface $f
$user_input = $form_state->getUserInput();
$storage_comparer = $form_state->get('storage_comparer');
if ($storage_comparer && empty($user_input)) {
$field_storages = \Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge(
$field_storages = ConfigImporterFieldPurger::getFieldStoragesToPurge(
$storage_comparer->getSourceStorage()->read('core.extension'),
$storage_comparer->getChangelist('delete')
);

View file

@ -222,6 +222,10 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
/**
* Constructs a FieldStorageConfig object.
*
* In most cases, Field entities are created via
* FieldStorageConfig::create($values)), where $values is the same parameter
* as in this constructor.
*
* @param array $values
* An array of field properties, keyed by property name. Most array
* elements will be used to set the corresponding properties on the class;
@ -232,10 +236,6 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
* - entity_type: required.
* - type: required.
*
* In most cases, Field entities are created via
* FieldStorageConfig::create($values)), where $values is the same
* parameter as in this constructor.
*
* @see entity_create()
*/
public function __construct(array $values, $entity_type = 'field_storage_config') {

View file

@ -79,7 +79,7 @@ class Field extends DrupalSqlBase {
['field_name' => $row->getSourceProperty('field_name')],
$this->t('Widget types @types are used in Drupal 6 field instances: widget type @selected_type applied to the Drupal 8 base field', [
'@types' => implode(', ', $widget_types),
'@selected_type' => $widget_types[0],
'@selected_type' => $widget_types[0],
])
);
}

View file

@ -37,7 +37,7 @@ class FieldHelpTest extends WebTestBase {
* Test the Field module's help page.
*/
public function testFieldHelp() {
// Login the admin user.
// Log in the admin user.
$this->drupalLogin($this->adminUser);
// Visit the Help page and make sure no warnings or notices are thrown.

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\field\Tests\FieldUnitTestBase.
*/
namespace Drupal\field\Tests;
use Drupal\Component\Utility\Unicode;

View file

@ -8,6 +8,7 @@
use Drupal\Core\Database\Database;
use Drupal\Component\Serialization\Yaml;
use Drupal\field\Entity\FieldStorageConfig;
$connection = Database::getConnection();
@ -59,8 +60,8 @@ $installed = $connection->select('key_value')
->execute()
->fetchField();
$installed = unserialize($installed);
$installed['field_ref_views_select_2429191'] = new \Drupal\field\Entity\FieldStorageConfig($field_ref_views_select_2429191);
$installed['field_ref_autocreate_2412569'] = new \Drupal\field\Entity\FieldStorageConfig($field_ref_autocreate_2412569);
$installed['field_ref_views_select_2429191'] = new FieldStorageConfig($field_ref_views_select_2429191);
$installed['field_ref_autocreate_2412569'] = new FieldStorageConfig($field_ref_autocreate_2412569);
$connection->update('key_value')
->condition('collection', 'entity.definitions.installed')
->condition('name', 'node.field_storage_definitions')

View file

@ -13,8 +13,9 @@
* test helper functions
*/
use Drupal\field\FieldStorageConfigInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\field\FieldStorageConfigInterface;
require_once __DIR__ . '/field_test.entity.inc';
require_once __DIR__ . '/field_test.field.inc';
@ -149,7 +150,7 @@ function field_test_entity_extra_field_info_alter(&$info) {
/**
* Implements hook_entity_bundle_field_info_alter().
*/
function field_test_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle) {
function field_test_entity_bundle_field_info_alter(&$fields, EntityTypeInterface $entity_type, $bundle) {
if (($field_name = \Drupal::state()->get('field_test_set_constraint', FALSE)) && $entity_type->id() == 'entity_test' && $bundle == 'entity_test' && !empty($fields[$field_name])) {
$fields[$field_name]->setPropertyConstraints('value', [
'Range' => [

View file

@ -5,12 +5,15 @@
* Test module.
*/
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FormatterInterface;
use Drupal\Core\Field\WidgetInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_field_widget_third_party_settings_form().
*/
function field_third_party_test_field_widget_third_party_settings_form(\Drupal\Core\Field\WidgetInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
function field_third_party_test_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
$element['field_test_widget_third_party_settings_form'] = array(
'#type' => 'textfield',
'#title' => t('3rd party widget settings form'),
@ -30,7 +33,7 @@ function field_third_party_test_field_widget_settings_summary_alter(&$summary, $
/**
* Implements hook_field_formatter_third_party_settings_form().
*/
function field_third_party_test_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) {
function field_third_party_test_field_formatter_third_party_settings_form(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) {
$element['field_test_field_formatter_third_party_settings_form'] = array(
'#type' => 'textfield',
'#title' => t('3rd party formatter settings form'),
@ -46,4 +49,3 @@ function field_third_party_test_field_formatter_settings_summary_alter(&$summary
$summary[] = 'field_test_field_formatter_settings_summary_alter';
return $summary;
}

View file

@ -104,7 +104,7 @@ class DisplayApiTest extends FieldKernelTestBase {
->setComponent($this->fieldName, $this->displayOptions['default'])
->save();
// Create a display for the teaser view mode.
EntityViewMode::create(array('id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save();
EntityViewMode::create(array('id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save();
entity_get_display($field['entity_type'], $field['bundle'], 'teaser')
->setComponent($this->fieldName, $this->displayOptions['teaser'])
->save();

View file

@ -5,6 +5,7 @@ namespace Drupal\Tests\field\Kernel\EntityReference;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
@ -204,6 +205,68 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
$this->assertEqual($build[1]['#markup'], $this->unsavedReferencedEntity->label(), sprintf('The markup returned by the %s formatter is correct for an item with a unsaved entity.', $formatter));
}
/**
* Tests the recursive rendering protection of the entity formatter.
*/
public function testEntityFormatterRecursiveRendering() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
$formatter = 'entity_reference_entity_view';
$view_builder = $this->entityManager->getViewBuilder($this->entityType);
// Set the default view mode to use the 'entity_reference_entity_view'
// formatter.
entity_get_display($this->entityType, $this->bundle, 'default')
->setComponent($this->fieldName, [
'type' => $formatter,
])
->save();
$referencing_entity_1 = entity_create($this->entityType, ['name' => $this->randomMachineName()]);
$referencing_entity_1->save();
// Create a self-reference.
$referencing_entity_1->{$this->fieldName}->entity = $referencing_entity_1;
$referencing_entity_1->save();
// Check that the recursive rendering stops after it reaches the specified
// limit.
$build = $view_builder->view($referencing_entity_1, 'default');
$output = $renderer->renderRoot($build);
// The title of entity_test entities is printed twice by default, so we have
// to multiply the formatter's recursive rendering protection limit by 2.
// Additionally, we have to take into account 2 additional occurrences of
// the entity title because we're rendering the full entity, not just the
// reference field.
$expected_occurrences = EntityReferenceEntityFormatter::RECURSIVE_RENDER_LIMIT * 2 + 2;
$actual_occurrences = substr_count($output, $referencing_entity_1->name->value);
$this->assertEqual($actual_occurrences, $expected_occurrences);
// Repeat the process with another entity in order to check that the
// 'recursive_render_id' counter is generated properly.
$referencing_entity_2 = entity_create($this->entityType, ['name' => $this->randomMachineName()]);
$referencing_entity_2->save();
$referencing_entity_2->{$this->fieldName}->entity = $referencing_entity_2;
$referencing_entity_2->save();
$build = $view_builder->view($referencing_entity_2, 'default');
$output = $renderer->renderRoot($build);
$actual_occurrences = substr_count($output, $referencing_entity_2->name->value);
$this->assertEqual($actual_occurrences, $expected_occurrences);
// Now render both entities at the same time and check again.
$build = $view_builder->viewMultiple([$referencing_entity_1, $referencing_entity_2], 'default');
$output = $renderer->renderRoot($build);
$actual_occurrences = substr_count($output, $referencing_entity_1->name->value);
$this->assertEqual($actual_occurrences, $expected_occurrences);
$actual_occurrences = substr_count($output, $referencing_entity_2->name->value);
$this->assertEqual($actual_occurrences, $expected_occurrences);
}
/**
* Tests the label formatter.
*/

View file

@ -229,7 +229,7 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
$this->assertEqual($vocabulary->label(), $new_name);
// Make sure the computed term reflects updates to the term id.
$vocabulary2 = $vocabulary = Vocabulary::create([
$vocabulary2 = $vocabulary = Vocabulary::create([
'name' => $this->randomMachineName(),
'vid' => Unicode::strtolower($this->randomMachineName()),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,

View file

@ -46,7 +46,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
$values[$current_revision] = $current_values;
}
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
$storage->resetCache();
$entity = $storage->load($entity_id);
// Confirm current revision loads the correct data.
@ -54,7 +54,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
$this->assertEqual(count($entity->{$this->fieldTestData->field_name}), $cardinality, 'Current revision: expected number of values');
for ($delta = 0; $delta < $cardinality; $delta++) {
// The field value loaded matches the one inserted or updated.
$this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value , $values[$current_revision][$delta]['value'], format_string('Current revision: expected value %delta was found.', array('%delta' => $delta)));
$this->assertEqual($entity->{$this->fieldTestData->field_name}[$delta]->value, $values[$current_revision][$delta]['value'], format_string('Current revision: expected value %delta was found.', array('%delta' => $delta)));
}
// Confirm each revision loads the correct data.
@ -363,7 +363,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Verify no data gets loaded
$controller = $this->container->get('entity.manager')->getStorage($entity->getEntityTypeId());
$controller->resetCache();
$entity= $controller->load($entity->id());
$entity = $controller->load($entity->id());
$this->assertTrue(empty($entity->{$this->fieldTestData->field_name}), 'No data for first field');
$this->assertTrue(empty($entity->{$field_name}), 'No data for second field');

View file

@ -95,7 +95,7 @@ class FieldCrudTest extends FieldKernelTestBase {
$this->assertIdentical($config['description'], '', 'Description defaults to empty string.');
// Check that default settings are set.
$this->assertEqual($config['settings'], $field_type_manager->getDefaultFieldSettings($this->fieldStorageDefinition['type']) , 'Default field settings have been written.');
$this->assertEqual($config['settings'], $field_type_manager->getDefaultFieldSettings($this->fieldStorageDefinition['type']), 'Default field settings have been written.');
// Check that the denormalized 'field_type' was properly written.
$this->assertEqual($config['field_type'], $this->fieldStorageDefinition['type']);

View file

@ -74,7 +74,7 @@ class FieldDataCountTest extends FieldKernelTestBase {
$this->assertIdentical($this->storage->countFieldData($field_storage), 0, 'There are 0 entities with field data.');
// Create 12 entities to ensure that the purging works as expected.
for ($i=0; $i < 12; $i++) {
for ($i = 0; $i < 12; $i++) {
$entity = EntityTest::create();
$entity->field_int[] = mt_rand(1, 99);
$entity->field_int[] = mt_rand(1, 99);
@ -135,7 +135,7 @@ class FieldDataCountTest extends FieldKernelTestBase {
$this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), TRUE, 'There are entities with field data.');
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
$storage = $this->container->get('entity.manager')->getStorage($entity_type);
$entity = $storage->loadRevision($first_revision);
$this->assertEqual(count($entity->{$this->fieldTestData->field_name_2}), $cardinality, format_string('Revision %revision_id: expected number of values.', array('%revision_id' => $first_revision)));
}

View file

@ -49,4 +49,3 @@ class FieldImportChangeTest extends FieldKernelTestBase {
$this->assertEqual($field->getLabel(), $new_label, 'field label updated');
}
}

View file

@ -116,4 +116,3 @@ class FieldImportCreateTest extends FieldKernelTestBase {
$this->assertTrue($field, 'Test import field 2b from sync exists');
}
}

View file

@ -109,4 +109,3 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
$this->assertTrue(empty($deleted_storages), 'Fields are deleted');
}
}

View file

@ -125,7 +125,7 @@ class FieldImportDeleteUninstallTest extends FieldKernelTestBase {
])->save();
// Create 12 entities to ensure that the purging works as expected.
for ($i=0; $i < 12; $i++) {
for ($i = 0; $i < 12; $i++) {
$entity = EntityTest::create();
$value = '+0123456789';
$entity->field_test = $value;

View file

@ -109,9 +109,9 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
),
'settings' =>
array (
'display_summary' => true,
'display_summary' => TRUE,
'text_processing' => 1,
'user_register_form' => false,
'user_register_form' => FALSE,
),
'display' =>
array (
@ -136,7 +136,7 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
'weight' => 0,
),
),
'required' => false,
'required' => FALSE,
'description' => '',
)),
))

View file

@ -140,7 +140,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$this->fieldTypePluginManager->expects($this->any())
->method('getDefinition')
->with('test_field')
->willReturn(['provider' => 'test_module', 'config_dependencies' =>['module' => ['test_module2']], 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']);
->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']);
$this->fieldStorage->expects($this->once())
->method('getConfigDependencyName')
@ -201,7 +201,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$this->fieldTypePluginManager->expects($this->any())
->method('getDefinition')
->with('test_field')
->willReturn(['provider' => 'test_module', 'config_dependencies' =>['module' => ['test_module2']], 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']);
->willReturn(['provider' => 'test_module', 'config_dependencies' => ['module' => ['test_module2']], 'class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']);
$field = new FieldConfig(array(
'field_name' => $this->fieldStorage->getName(),