Update to drupal-org-drupal 8.0.0-rc2. For more information, see https://www.drupal.org/node/2598668
This commit is contained in:
parent
f32e58e4b1
commit
8e18df8c36
3062 changed files with 15044 additions and 172506 deletions
|
@ -5,8 +5,6 @@
|
|||
* @{
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
|
||||
/**
|
||||
* @defgroup field_types Field Types API
|
||||
* @{
|
||||
|
|
|
@ -28,7 +28,14 @@ process:
|
|||
index:
|
||||
- 1
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: type_name
|
||||
bundle:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_node_type
|
||||
source: type_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
view_mode:
|
||||
-
|
||||
plugin: migration
|
||||
|
|
|
@ -28,7 +28,14 @@ process:
|
|||
method: row
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: field_name
|
||||
bundle: type_name
|
||||
bundle:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_node_type
|
||||
source: type_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
label: label
|
||||
description: description
|
||||
required: required
|
||||
|
|
|
@ -28,7 +28,14 @@ process:
|
|||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
bundle: type_name
|
||||
bundle:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_node_type
|
||||
source: type_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
form_mode: 'constants/form_mode'
|
||||
field_name: field_name
|
||||
entity_type: 'constants/entity_type'
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\field\Entity;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Field\FieldConfigBase;
|
||||
use Drupal\Core\Field\FieldException;
|
||||
|
@ -185,7 +184,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface {
|
|||
*/
|
||||
public function calculateDependencies() {
|
||||
parent::calculateDependencies();
|
||||
// Mark the field_storage_config as a a dependency.
|
||||
// Mark the field_storage_config as a dependency.
|
||||
$this->addDependency('config', $this->getFieldStorageDefinition()->getConfigDependencyName());
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -82,6 +82,9 @@ class FieldInstance extends DrupalSqlBase {
|
|||
$row->setSourceProperty('widget_settings', $data['widget']);
|
||||
$row->setSourceProperty('display_settings', $data['display']);
|
||||
|
||||
// This is for parity with the d6_field_instance plugin.
|
||||
$row->setSourceProperty('widget_type', $data['widget']['type']);
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\field\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate\Annotation\MigrateSource;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,8 +9,6 @@ namespace Drupal\field\Tests\Boolean;
|
|||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
||||
use Drupal\Core\Entity\FieldableEntityInterface;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Drupal\field\Tests\EntityReference;
|
|||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\config\Tests\AssertConfigEntityImportTrait;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
|
@ -88,7 +87,7 @@ class EntityReferenceIntegrationTest extends WebTestBase {
|
|||
// Try to post the form again with no modification and check if the field
|
||||
// values remain the same.
|
||||
$entity = current(entity_load_multiple_by_properties($this->entityType, array('name' => $entity_name)));
|
||||
$this->drupalGet($this->entityType . '/manage/' . $entity->id());
|
||||
$this->drupalGet($this->entityType . '/manage/' . $entity->id() . '/edit');
|
||||
$this->assertFieldByName($this->fieldName . '[0][target_id]', $referenced_entities[0]->label() . ' (' . $referenced_entities[0]->id() . ')');
|
||||
$this->assertFieldByName($this->fieldName . '[1][target_id]', $referenced_entities[1]->label() . ' (' . $referenced_entities[1]->id() . ')');
|
||||
|
||||
|
@ -114,7 +113,7 @@ class EntityReferenceIntegrationTest extends WebTestBase {
|
|||
// Try to post the form again with no modification and check if the field
|
||||
// values remain the same.
|
||||
$entity = current(entity_load_multiple_by_properties($this->entityType, array('name' => $entity_name)));
|
||||
$this->drupalGet($this->entityType . '/manage/' . $entity->id());
|
||||
$this->drupalGet($this->entityType . '/manage/' . $entity->id() . '/edit');
|
||||
$this->assertFieldByName($this->fieldName . '[target_id]', $target_id . ' (' . $referenced_entities[1]->id() . ')');
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Save'));
|
||||
|
@ -133,7 +132,7 @@ class EntityReferenceIntegrationTest extends WebTestBase {
|
|||
'type' => $widget_type,
|
||||
))->save();
|
||||
|
||||
$this->drupalPostForm($this->entityType . '/manage/' . $entity->id(), array(), t('Save'));
|
||||
$this->drupalPostForm($this->entityType . '/manage/' . $entity->id() . '/edit', array(), t('Save'));
|
||||
$this->assertFieldValues($entity_name, $referenced_entities);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\field\Tests;
|
||||
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
||||
/**
|
||||
* Tests other Field API functions.
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
namespace Drupal\field\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\entity_test\Entity\EntityTestBaseFieldDisplay;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
|
@ -137,7 +139,7 @@ class FormTest extends FieldTestBase {
|
|||
$this->assertEqual($entity->{$field_name}->value, $value, 'Field value was saved');
|
||||
|
||||
// Display edit form.
|
||||
$this->drupalGet('entity_test/manage/' . $id);
|
||||
$this->drupalGet('entity_test/manage/' . $id . '/edit');
|
||||
$this->assertFieldByName("{$field_name}[0][value]", $value, 'Widget is displayed with the correct default value');
|
||||
$this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
|
||||
|
||||
|
@ -157,7 +159,7 @@ class FormTest extends FieldTestBase {
|
|||
$edit = array(
|
||||
"{$field_name}[0][value]" => $value
|
||||
);
|
||||
$this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save'));
|
||||
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
|
||||
$this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated');
|
||||
$this->container->get('entity.manager')->getStorage('entity_test')->resetCache(array($id));
|
||||
$entity = entity_load('entity_test', $id);
|
||||
|
@ -229,7 +231,7 @@ class FormTest extends FieldTestBase {
|
|||
$edit = array(
|
||||
"{$field_name}[0][value]" => $value,
|
||||
);
|
||||
$this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save'));
|
||||
$this->drupalPostForm('entity_test/manage/' . $id . '/edit', $edit, t('Save'));
|
||||
$this->assertRaw(t('@name field is required.', array('@name' => $this->field['label'])), 'Required field with no value fails validation');
|
||||
}
|
||||
|
||||
|
@ -489,7 +491,7 @@ class FormTest extends FieldTestBase {
|
|||
$this->assertFieldValues($entity_init, $field_name, array(1, 2, 3));
|
||||
|
||||
// Display the form, check that the values are correctly filled in.
|
||||
$this->drupalGet('entity_test/manage/' . $id);
|
||||
$this->drupalGet('entity_test/manage/' . $id . '/edit');
|
||||
$this->assertFieldByName($field_name, '1, 2, 3', 'Widget is displayed.');
|
||||
|
||||
// Submit the form with more values than the field accepts.
|
||||
|
@ -572,7 +574,7 @@ class FormTest extends FieldTestBase {
|
|||
"{$field_name}[0][value]" => 2,
|
||||
'revision' => TRUE,
|
||||
);
|
||||
$this->drupalPostForm($entity_type . '/manage/' . $id, $edit, t('Save'));
|
||||
$this->drupalPostForm($entity_type . '/manage/' . $id . '/edit', $edit, t('Save'));
|
||||
|
||||
// Check that the new revision has the expected values.
|
||||
$this->container->get('entity.manager')->getStorage($entity_type)->resetCache(array($id));
|
||||
|
@ -628,7 +630,7 @@ class FormTest extends FieldTestBase {
|
|||
->save();
|
||||
|
||||
// Display edit form.
|
||||
$this->drupalGet($entity_type . '/manage/' . $id);
|
||||
$this->drupalGet($entity_type . '/manage/' . $id . '/edit');
|
||||
$this->assertFieldByName("{$field_name}[0][value]", 99, 'Widget is displayed with the correct default value');
|
||||
|
||||
// Update the entity.
|
||||
|
@ -647,7 +649,7 @@ class FormTest extends FieldTestBase {
|
|||
|
||||
// Create a new revision.
|
||||
$edit = array('revision' => TRUE);
|
||||
$this->drupalPostForm($entity_type . '/manage/' . $id, $edit, t('Save'));
|
||||
$this->drupalPostForm($entity_type . '/manage/' . $id . '/edit', $edit, t('Save'));
|
||||
|
||||
// Check that the expected value has been carried over to the new revision.
|
||||
\Drupal::entityManager()->getStorage($entity_type)->resetCache(array($id));
|
||||
|
@ -655,4 +657,40 @@ class FormTest extends FieldTestBase {
|
|||
$this->assertEqual($entity->{$field_name}->value, $value, 'New revision has the expected value for the field with the Hidden widget');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the form display of the label for multi-value fields.
|
||||
*/
|
||||
public function testLabelOnMultiValueFields() {
|
||||
$user = $this->drupalCreateUser(['administer entity_test content']);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
FieldStorageConfig::create([
|
||||
'entity_type' => 'entity_test_base_field_display',
|
||||
'field_name' => 'foo',
|
||||
'type' => 'text',
|
||||
'cardinality' => FieldStorageConfig::CARDINALITY_UNLIMITED,
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test_base_field_display',
|
||||
'bundle' => 'bar',
|
||||
'field_name' => 'foo',
|
||||
// Set a dangerous label to test XSS filtering.
|
||||
'label' => "<script>alert('a configurable field');</script>",
|
||||
])->save();
|
||||
EntityFormDisplay::create([
|
||||
'targetEntityType' => 'entity_test_base_field_display',
|
||||
'bundle' => 'bar',
|
||||
'mode' => 'default',
|
||||
])->setComponent('foo', ['type' => 'text_textfield'])->enable()->save();
|
||||
|
||||
$entity = EntityTestBaseFieldDisplay::create(['type' => 'bar']);
|
||||
$entity->save();
|
||||
|
||||
$this->drupalGet('entity_test_base_field_display/manage/' . $entity->id());
|
||||
$this->assertResponse(200);
|
||||
$this->assertText('A field with multiple values');
|
||||
// Test if labels were XSS filtered.
|
||||
$this->assertEscaped("<script>alert('a configurable field');</script>");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\field\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Entity\Entity\EntityViewMode;
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
|
|
|
@ -19,18 +19,12 @@ use Drupal\node\Entity\Node;
|
|||
*/
|
||||
class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->migrateFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of file variables to file.settings.yml.
|
||||
*/
|
||||
public function testFieldInstanceSettings() {
|
||||
public function testFieldInstanceMigration() {
|
||||
$this->migrateFields();
|
||||
|
||||
$entity = Node::create(['type' => 'story']);
|
||||
// Test a text field.
|
||||
$field = FieldConfig::load('node.story.field_test');
|
||||
|
@ -98,4 +92,20 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
|
|||
$this->assertIdentical([], $entity->field_test_link->options['attributes']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migrating fields into non-existent content types.
|
||||
*/
|
||||
public function testMigrateFieldIntoUnknownNodeType() {
|
||||
$this->sourceDatabase->delete('node_type')
|
||||
->condition('type', 'test_planet')
|
||||
->execute();
|
||||
// The field migrations use the migration plugin to ensure that the node
|
||||
// types exist, so this should produce no failures...
|
||||
$this->migrateFields();
|
||||
|
||||
// ...and the field instances should not have been migrated.
|
||||
$this->assertNull(FieldConfig::load('node.test_planet.field_multivalue'));
|
||||
$this->assertNull(FieldConfig::load('node.test_planet.field_test_text_single_checkbox'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ class TranslationWebTest extends FieldTestBase {
|
|||
"{$field_name}[0][value]" => $entity->{$field_name}->value,
|
||||
'revision' => TRUE,
|
||||
);
|
||||
$this->drupalPostForm($this->entityTypeId . '/manage/' . $entity->id(), $edit, t('Save'));
|
||||
$this->drupalPostForm($this->entityTypeId . '/manage/' . $entity->id() . '/edit', $edit, t('Save'));
|
||||
|
||||
// Check translation revisions.
|
||||
$this->checkTranslationRevisions($entity->id(), $entity->getRevisionId(), $available_langcodes);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?php
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\field\FieldStorageConfigInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
|
||||
namespace Drupal\field_test\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\TypedData\DataDefinition;
|
||||
|
||||
/**
|
||||
* Defines the 'hidden_test' entity field item.
|
||||
*
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Drupal\Tests\field\Unit;
|
|||
|
||||
use Drupal\Core\Entity\EntityType;
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
@ -213,6 +212,35 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
$field->calculateDependencies();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::onDependencyRemoval
|
||||
*/
|
||||
public function testOnDependencyRemoval() {
|
||||
$this->fieldTypePluginManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with('test_field')
|
||||
->willReturn(['class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']);
|
||||
|
||||
$field = new FieldConfig([
|
||||
'field_name' => $this->fieldStorage->getName(),
|
||||
'entity_type' => 'test_entity_type',
|
||||
'bundle' => 'test_bundle',
|
||||
'field_type' => 'test_field',
|
||||
'dependencies' => [
|
||||
'module' => [
|
||||
'fruiter',
|
||||
]
|
||||
],
|
||||
'third_party_settings' => [
|
||||
'fruiter' => [
|
||||
'fruit' => 'apple',
|
||||
]
|
||||
]
|
||||
]);
|
||||
$changed = $field->onDependencyRemoval(['module' => ['fruiter']]);
|
||||
$this->assertTrue($changed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::toArray
|
||||
*/
|
||||
|
@ -291,4 +319,7 @@ class DependencyFieldItem {
|
|||
return ['module' => ['test_module3']];
|
||||
}
|
||||
|
||||
public static function onDependencyRemoval($field_config, $dependencies) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
namespace Drupal\Tests\field\Unit;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Field\FieldItemBase;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldTypePluginManagerInterface;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
|
Reference in a new issue