Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713
This commit is contained in:
parent
c0a0d5a94c
commit
9eae24d844
669 changed files with 3873 additions and 1553 deletions
|
@ -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')
|
||||
|
|
|
@ -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' => [
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -49,4 +49,3 @@ class FieldImportChangeTest extends FieldKernelTestBase {
|
|||
$this->assertEqual($field->getLabel(), $new_label, 'field label updated');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,4 +116,3 @@ class FieldImportCreateTest extends FieldKernelTestBase {
|
|||
$this->assertTrue($field, 'Test import field 2b from sync exists');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,4 +109,3 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
|
|||
$this->assertTrue(empty($deleted_storages), 'Fields are deleted');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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' => '',
|
||||
)),
|
||||
))
|
||||
|
|
|
@ -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(),
|
||||
|
|
Reference in a new issue