diff --git a/core/modules/field/tests/modules/field_test_views/test_views/views.view.test_view_field_delete.yml b/core/modules/field/tests/modules/field_test_views/test_views/views.view.test_view_field_delete.yml new file mode 100644 index 0000000..16e9cb1 --- /dev/null +++ b/core/modules/field/tests/modules/field_test_views/test_views/views.view.test_view_field_delete.yml @@ -0,0 +1,52 @@ +langcode: en +status: true +dependencies: + module: + - node + - user + config: + - field.storage.node.field_test +id: test_view_field_delete +label: test_view_field_delete +module: views +description: '' +tag: default +base_table: node +base_field: nid +core: '8' +display: + default: + display_options: + access: + type: perm + fields: + nid: + field: nid + id: nid + table: node + plugin_id: field + entity_type: node + entity_field: nid + field_test: + id: field_test + table: node__field_test + field: field_test + plugin_id: field + entity_type: node + entity_field: field_test + cache: + type: tag + exposed_form: + type: basic + pager: + type: full + query: + type: views_query + style: + type: default + row: + type: fields + display_plugin: default + display_title: Master + id: default + position: 0 diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index f1db4d4..fd049d1 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -15,6 +15,7 @@ use Drupal\field\Entity\FieldStorageConfig; use Drupal\simpletest\WebTestBase; use Drupal\taxonomy\Entity\Vocabulary; +use Drupal\views\Tests\ViewTestData; /** * Tests the Field UI "Manage fields" screen. @@ -31,7 +32,7 @@ class ManageFieldsTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'field_ui', 'field_test', 'taxonomy', 'image', 'block'); + public static $modules = array('node', 'field_ui', 'field_test', 'taxonomy', 'image', 'block', 'field_test_views'); /** * The ID of the custom content type created for testing. @@ -62,6 +63,13 @@ class ManageFieldsTest extends WebTestBase { protected $fieldName; /** + * Test views to enable + * + * @var string[] + */ + public static $testViews = array('test_view_field_delete'); + + /** * {@inheritdoc} */ protected function setUp() { @@ -82,7 +90,7 @@ protected function setUp() { // Create random field name with markup to test escaping. $this->fieldLabel = '' . $this->randomMachineName(8) . ''; - $this->fieldNameInput = strtolower($this->randomMachineName(8)); + $this->fieldNameInput = 'test'; $this->fieldName = 'field_'. $this->fieldNameInput; // Create Basic page and Article node types. @@ -445,6 +453,9 @@ function testDefaultValue() { * Tests that deletion removes field storages and fields as expected. */ function testDeleteField() { + + $this->fieldLabel = $this->randomMachineName(); + // Create a new field. $bundle_path1 = 'admin/structure/types/manage/' . $this->contentType; $this->fieldUIAddNewField($bundle_path1, $this->fieldNameInput, $this->fieldLabel); @@ -458,6 +469,13 @@ function testDeleteField() { $bundle_path2 = 'admin/structure/types/manage/' . $type_name2; $this->fieldUIAddExistingField($bundle_path2, $this->fieldName, $this->fieldLabel); + // Check the config dependencies of the first field, the field storage must + // not be shown as being deleted yet. + $this->drupalGet("$bundle_path1/fields/node.$this->contentType.$this->fieldName/delete"); + $this->assertNoText(t('The listed configuration will be deleted.')); + $this->assertNoText(t('View')); + $this->assertNoText('test_view_field_delete'); + // Delete the first field. $this->fieldUIDeleteField($bundle_path1, "node.$this->contentType.$this->fieldName", $this->fieldLabel, $this->contentType); @@ -466,6 +484,19 @@ function testDeleteField() { // Check that the field storage was not deleted $this->assertNotNull(FieldStorageConfig::loadByName('node', $this->fieldName), 'Field storage was not deleted.'); + \Drupal::service('module_installer')->install(['views']); + ViewTestData::createTestViews(get_class($this), array('field_test_views')); + + // Check the config dependencies of the first field. + $this->drupalGet("$bundle_path2/fields/node.$type_name2.$this->fieldName/delete"); + $this->assertText(t('The listed configuration will be deleted.')); + $this->assertText(t('View')); + $this->assertText('test_view_field_delete'); + + $xml = $this->cssSelect('#edit-entity-deletes'); + // Remove the wrapping HTML. + $this->assertIdentical(FALSE, strpos($xml[0]->asXml(), $this->fieldLabel), 'The currently being deleted field is not shown in the entity deletions.'); + // Delete the second field. $this->fieldUIDeleteField($bundle_path2, "node.$type_name2.$this->fieldName", $this->fieldLabel, $type_name2);