update drupal
This commit is contained in:
@@ -40,7 +40,7 @@ class FieldOptionTranslation extends ProcessPluginBase {
|
||||
$i = 0;
|
||||
foreach ($list as $allowed_value) {
|
||||
// Get the key for this allowed value which may be a key|label pair
|
||||
// or or just key.
|
||||
// or just key.
|
||||
$value = explode("|", $allowed_value);
|
||||
if (isset($value[0]) && ($value[0] == $option)) {
|
||||
$allowed_values = ['label' => $row->getSourceProperty('translation')];
|
||||
|
||||
+9
@@ -57,6 +57,15 @@ display:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
sorts:
|
||||
nid:
|
||||
id: nid
|
||||
table: node_field_data
|
||||
field: nid
|
||||
order: ASC
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: nid
|
||||
display_plugin: default
|
||||
display_title: Master
|
||||
id: default
|
||||
|
||||
+48
-1
@@ -19,7 +19,7 @@ class EntityReferenceAutoCreateTest extends BrowserTestBase {
|
||||
|
||||
use EntityReferenceTestTrait;
|
||||
|
||||
public static $modules = ['node', 'taxonomy'];
|
||||
public static $modules = ['node', 'taxonomy', 'entity_test'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -237,4 +237,51 @@ class EntityReferenceAutoCreateTest extends BrowserTestBase {
|
||||
// $this->assertErrorLogged($error_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests autocreation for an entity that has no bundles.
|
||||
*/
|
||||
public function testNoBundles() {
|
||||
$account = $this->drupalCreateUser([
|
||||
'access content',
|
||||
"create $this->referencingType content",
|
||||
'administer entity_test content',
|
||||
]);
|
||||
$this->drupalLogin($account);
|
||||
|
||||
$field_name = mb_strtolower($this->randomMachineName());
|
||||
$handler_settings = [
|
||||
'auto_create' => TRUE,
|
||||
];
|
||||
$this->createEntityReferenceField('node', $this->referencingType, $field_name, $this->randomString(), 'entity_test_no_bundle_with_label', 'default', $handler_settings);
|
||||
\Drupal::service('entity_display.repository')
|
||||
->getFormDisplay('node', $this->referencingType)
|
||||
->setComponent($field_name, ['type' => 'entity_reference_autocomplete'])
|
||||
->save();
|
||||
|
||||
$node_title = $this->randomMachineName();
|
||||
$name = $this->randomMachineName();
|
||||
$edit = [
|
||||
$field_name . '[0][target_id]' => $name,
|
||||
'title[0][value]' => $node_title,
|
||||
];
|
||||
|
||||
$this->drupalPostForm('node/add/' . $this->referencingType, $edit, 'Save');
|
||||
|
||||
// Assert referenced entity was created.
|
||||
$result = \Drupal::entityQuery('entity_test_no_bundle_with_label')
|
||||
->condition('name', $name)
|
||||
->execute();
|
||||
$this->assertNotEmpty($result, 'Referenced entity was created.');
|
||||
$referenced_id = key($result);
|
||||
|
||||
// Assert the referenced entity is associated with referencing node.
|
||||
$result = \Drupal::entityQuery('node')
|
||||
->condition('type', $this->referencingType)
|
||||
->execute();
|
||||
$this->assertCount(1, $result);
|
||||
$referencing_nid = key($result);
|
||||
$referencing_node = Node::load($referencing_nid);
|
||||
$this->assertEqual($referenced_id, $referencing_node->$field_name->target_id, 'Newly created node is referenced from the referencing entity.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -311,7 +311,8 @@ class FormTest extends FieldTestBase {
|
||||
}
|
||||
ksort($pattern);
|
||||
$pattern = implode('.*', array_values($pattern));
|
||||
$this->assertPattern("|$pattern|s", 'Widgets are displayed in the correct order');
|
||||
// Verify that the widgets are displayed in the correct order.
|
||||
$this->assertPattern("|$pattern|s");
|
||||
$this->assertFieldByName("{$field_name}[$delta][value]", '', "New widget is displayed");
|
||||
$this->assertFieldByName("{$field_name}[$delta][_weight]", $delta, "New widget has the right weight");
|
||||
$this->assertNoField("{$field_name}[" . ($delta + 1) . '][value]', 'No extraneous widget is displayed');
|
||||
|
||||
@@ -344,10 +344,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
|
||||
// bundle.
|
||||
$actual_hooks = field_test_memorize();
|
||||
$hooks = [];
|
||||
$entities = $this->entitiesByBundles[$bundle];
|
||||
foreach ($entities as $id => $entity) {
|
||||
$hooks['field_test_field_delete'][] = $entity;
|
||||
}
|
||||
$hooks['field_test_field_delete'] = $this->entitiesByBundles[$bundle];
|
||||
$this->checkHooksInvocations($hooks, $actual_hooks);
|
||||
|
||||
// The field still exists, deleted.
|
||||
@@ -395,10 +392,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
|
||||
// bundle.
|
||||
$actual_hooks = field_test_memorize();
|
||||
$hooks = [];
|
||||
$entities = $this->entitiesByBundles[$bundle];
|
||||
foreach ($entities as $id => $entity) {
|
||||
$hooks['field_test_field_delete'][] = $entity;
|
||||
}
|
||||
$hooks['field_test_field_delete'] = $this->entitiesByBundles[$bundle];
|
||||
$this->checkHooksInvocations($hooks, $actual_hooks);
|
||||
|
||||
// The field still exists, deleted.
|
||||
@@ -430,10 +424,7 @@ class BulkDeleteTest extends FieldKernelTestBase {
|
||||
// Check hooks invocations (same as above, for the 2nd bundle).
|
||||
$actual_hooks = field_test_memorize();
|
||||
$hooks = [];
|
||||
$entities = $this->entitiesByBundles[$bundle];
|
||||
foreach ($entities as $id => $entity) {
|
||||
$hooks['field_test_field_delete'][] = $entity;
|
||||
}
|
||||
$hooks['field_test_field_delete'] = $this->entitiesByBundles[$bundle];
|
||||
$this->checkHooksInvocations($hooks, $actual_hooks);
|
||||
|
||||
// The field and the storage still exist, deleted.
|
||||
|
||||
+4
-9
@@ -90,15 +90,10 @@ class SqlContentEntityStorageSchemaColumnTest extends KernelTestBase {
|
||||
|
||||
// Now attempt to run automatic updates. An exception should be thrown
|
||||
// since there is data in the table.
|
||||
try {
|
||||
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
||||
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('test', 'entity_test_rev');
|
||||
$entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
|
||||
$this->fail('Failed to detect a schema change in a field with data.');
|
||||
}
|
||||
catch (FieldStorageDefinitionUpdateForbiddenException $e) {
|
||||
$this->pass('Detected a schema change in a field with data.');
|
||||
}
|
||||
$this->expectException(FieldStorageDefinitionUpdateForbiddenException::class);
|
||||
$entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
|
||||
$field_storage_definition = $entity_definition_update_manager->getFieldStorageDefinition('test', 'entity_test_rev');
|
||||
$entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -187,8 +187,8 @@ class EntityReferenceItemTest extends FieldKernelTestBase {
|
||||
$entity->field_test_taxonomy_term = ['target_id' => 'invalid', 'entity' => $term2];
|
||||
$this->fail('Assigning an invalid item throws an exception.');
|
||||
}
|
||||
catch (\InvalidArgumentException $e) {
|
||||
$this->pass('Assigning an invalid item throws an exception.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(\InvalidArgumentException::class, $e);
|
||||
}
|
||||
|
||||
// Delete terms so we have nothing to reference and try again
|
||||
|
||||
@@ -103,7 +103,7 @@ class FieldCrudTest extends FieldKernelTestBase {
|
||||
$this->fail('Cannot create two fields with the same field / bundle combination.');
|
||||
}
|
||||
catch (EntityStorageException $e) {
|
||||
$this->pass('Cannot create two fields with the same field / bundle combination.');
|
||||
// Expected exception; just continue testing.
|
||||
}
|
||||
|
||||
// Check that the specified field exists.
|
||||
@@ -113,7 +113,7 @@ class FieldCrudTest extends FieldKernelTestBase {
|
||||
$this->fail('Cannot create a field with a non-existing storage.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create a field with a non-existing storage.');
|
||||
// Expected exception; just continue testing.
|
||||
}
|
||||
|
||||
// TODO: test other failures.
|
||||
|
||||
@@ -65,46 +65,25 @@ class FieldDefinitionIntegrityTest extends KernelTestBase {
|
||||
foreach ($field_type_manager->getDefinitions() as $definition) {
|
||||
// Test default field widgets.
|
||||
if (isset($definition['default_widget'])) {
|
||||
if (in_array($definition['default_widget'], $available_field_widget_ids)) {
|
||||
$this->pass(sprintf('Field type %s uses an existing field widget by default.', $definition['id']));
|
||||
}
|
||||
else {
|
||||
$this->fail(sprintf('Field type %s uses a non-existent field widget by default: %s', $definition['id'], $definition['default_widget']));
|
||||
}
|
||||
$this->assertContains($definition['default_widget'], $available_field_widget_ids, sprintf('Field type %s uses a non-existent field widget by default: %s', $definition['id'], $definition['default_widget']));
|
||||
}
|
||||
|
||||
// Test default field formatters.
|
||||
if (isset($definition['default_formatter'])) {
|
||||
if (in_array($definition['default_formatter'], $available_field_formatter_ids)) {
|
||||
$this->pass(sprintf('Field type %s uses an existing field formatter by default.', $definition['id']));
|
||||
}
|
||||
else {
|
||||
$this->fail(sprintf('Field type %s uses a non-existent field formatter by default: %s', $definition['id'], $definition['default_formatter']));
|
||||
}
|
||||
$this->assertContains($definition['default_formatter'], $available_field_formatter_ids, sprintf('Field type %s uses a non-existent field formatter by default: %s', $definition['id'], $definition['default_formatter']));
|
||||
}
|
||||
}
|
||||
|
||||
// Test the field widget plugins.
|
||||
foreach ($field_widget_manager->getDefinitions() as $definition) {
|
||||
$missing_field_type_ids = array_diff($definition['field_types'], $available_field_type_ids);
|
||||
if ($missing_field_type_ids) {
|
||||
$this->fail(sprintf('Field widget %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
|
||||
}
|
||||
else {
|
||||
$this->pass(sprintf('Field widget %s integrates with existing field types.', $definition['id']));
|
||||
}
|
||||
$this->assertEmpty($missing_field_type_ids, sprintf('Field widget %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
|
||||
}
|
||||
|
||||
// Test the field formatter plugins.
|
||||
foreach ($field_formatter_manager->getDefinitions() as $definition) {
|
||||
$missing_field_type_ids = array_diff($definition['field_types'], $available_field_type_ids);
|
||||
if ($missing_field_type_ids) {
|
||||
$this->fail(sprintf('Field formatter %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
|
||||
}
|
||||
else {
|
||||
$this->pass(sprintf('Field formatter %s integrates with existing field types.', $definition['id']));
|
||||
}
|
||||
|
||||
$this->assertEmpty($missing_field_type_ids, sprintf('Field formatter %s integrates with non-existent field types: %s', $definition['id'], implode(', ', $missing_field_type_ids)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,8 +80,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create two fields with the same name.');
|
||||
}
|
||||
catch (EntityStorageException $e) {
|
||||
$this->pass('Cannot create two fields with the same name.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(EntityStorageException::class, $e);
|
||||
}
|
||||
|
||||
// Check that field type is required.
|
||||
@@ -93,8 +93,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create a field with no type.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create a field with no type.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
|
||||
// Check that field name is required.
|
||||
@@ -106,8 +106,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create an unnamed field.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create an unnamed field.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
// Check that entity type is required.
|
||||
try {
|
||||
@@ -118,8 +118,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create a field without an entity type.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create a field without an entity type.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
|
||||
// Check that field name must start with a letter or _.
|
||||
@@ -132,8 +132,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create a field with a name starting with a digit.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create a field with a name starting with a digit.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
|
||||
// Check that field name must only contain lowercase alphanumeric or _.
|
||||
@@ -146,8 +146,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create a field with a name containing an illegal character.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create a field with a name containing an illegal character.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
|
||||
// Check that field name cannot be longer than 32 characters long.
|
||||
@@ -160,8 +160,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create a field with a name longer than 32 characters.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create a field with a name longer than 32 characters.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
|
||||
// Check that field name can not be an entity key.
|
||||
@@ -175,8 +175,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
FieldStorageConfig::create($field_storage_definition)->save();
|
||||
$this->fail('Cannot create a field bearing the name of an entity key.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot create a field bearing the name of an entity key.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,8 +380,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
$field_storage->save();
|
||||
$this->fail('Cannot update a field to a different type.');
|
||||
}
|
||||
catch (FieldException $e) {
|
||||
$this->pass('Cannot update a field to a different type.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldException::class, $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,7 +480,6 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
$field_storage->setSetting('changeable', $field_storage->getSetting('changeable') + 1);
|
||||
try {
|
||||
$field_storage->save();
|
||||
$this->pass('A changeable setting can be updated.');
|
||||
}
|
||||
catch (FieldStorageDefinitionUpdateForbiddenException $e) {
|
||||
$this->fail('An unchangeable setting cannot be updated.');
|
||||
@@ -490,8 +489,8 @@ class FieldStorageCrudTest extends FieldKernelTestBase {
|
||||
$field_storage->save();
|
||||
$this->fail('An unchangeable setting can be updated.');
|
||||
}
|
||||
catch (FieldStorageDefinitionUpdateForbiddenException $e) {
|
||||
$this->pass('An unchangeable setting cannot be updated.');
|
||||
catch (\Exception $e) {
|
||||
$this->assertInstanceOf(FieldStorageDefinitionUpdateForbiddenException::class, $e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -128,6 +128,8 @@ class MigrateFieldFormatterSettingsTest extends MigrateDrupal7TestBase {
|
||||
|
||||
$this->assertEntity('node.blog.teaser');
|
||||
$this->assertComponent('node.blog.teaser', 'body', 'text_summary_or_trimmed', 'hidden', 0);
|
||||
$this->assertComponent('node.blog.default', 'field_termplain', 'entity_reference_label', 'above', 13);
|
||||
$this->assertComponent('node.blog.default', 'field_termrss', 'entity_reference_label', 'above', 14);
|
||||
|
||||
$this->assertEntity('node.book.default');
|
||||
$this->assertComponent('node.book.default', 'body', 'text_default', 'hidden', 0);
|
||||
|
||||
@@ -167,12 +167,8 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
|
||||
$this->assertEntity('node.article.field_vocab_fixed', 'vocab_fixed', 'entity_reference', FALSE, TRUE);
|
||||
$this->assertEntity('node.article.field_vocab_localize', 'vocab_localize', 'entity_reference', FALSE, FALSE);
|
||||
$this->assertEntity('node.article.field_vocab_translate', 'vocab_translate', 'entity_reference', FALSE, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration of text field instances with different text processing.
|
||||
*/
|
||||
public function testTextFieldInstances() {
|
||||
// Test migration of text field instances with different text processing.
|
||||
// All text and text_long field instances using a field base that has only
|
||||
// plain text instances should be migrated to string and string_long fields.
|
||||
// All text_with_summary field instances using a field base that has only
|
||||
|
||||
@@ -142,12 +142,8 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
|
||||
// have a datetime_type setting.
|
||||
$field = FieldStorageConfig::load('node.field_date_with_end_time');
|
||||
$this->assertNull($field->getSetting('datetime_type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the migration of text fields with different text processing.
|
||||
*/
|
||||
public function testTextFields() {
|
||||
// Test the migration of text fields with different text processing.
|
||||
// All text and text_long field bases that have only plain text instances
|
||||
// should be migrated to string and string_long fields.
|
||||
// All text_with_summary field bases that have only plain text instances
|
||||
|
||||
Reference in New Issue
Block a user