Skip to content
Snippets Groups Projects
Verified Commit 6b661927 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3465968 by catch: De-duplicate logic in ManageFieldsFunctionalTest

(cherry picked from commit 71ae8fcb)
parent e41b685b
Branches
Tags
17 merge requests!10663Issue #3495778: Update phpdoc in FileSaveHtaccessLoggingTest,!10451Issue #3472458 by watergate, smustgrave: CKEditor 5 show blocks label is not translated,!103032838547 Fix punctuation rules for inline label suffix colon with CSS only,!10150Issue #3467294 by quietone, nod_, smustgrave, catch, longwave: Change string...,!10130Resolve #3480321 "Second level menu",!9936Issue #3483087: Check the module:// prefix in the translation server path and replace it with the actual module path,!9933Issue #3394728 by ankondrat4: Undefined array key "#prefix" and deprecated function: explode() in Drupal\file\Element\ManagedFile::uploadAjaxCallback(),!9914Issue #3451136 by quietone, gapple, ghost of drupal past: Improve...,!9882Draft: Issue #3481777 In bulk_form ensure the triggering element is the bulk_form button,!9839Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9815Issue #3480025: There is no way to remove entity cache items,!9757Issue #3478869 Add "All" or overview links to parent links,!9752Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9749Issue #3439910 by pooja_sharma, vensires: Fix Toolbar tests that rely on UID1's super user behavior,!9678Issue #3465132 by catch, Spokje, nod_: Show test run time by class in run-tests.sh output,!9578Issue #3304746 by scott_euser, casey, smustgrave: BigPipe cannot handle (GET)...,!9449Issue #3344041: Allow textarea widgets to be used for text (formatted) fields
Pipeline #250376 canceled
......@@ -109,38 +109,6 @@ public function testDefaultValue(): void {
$this->assertSession()->fieldValueEquals($element_id, '');
}
/**
* Tests that Field UI respects disallowed field names.
*/
public function testDisallowedFieldNames(): void {
// Reset the field prefix so we can test properly.
$this->config('field_ui.settings')->set('field_prefix', '')->save();
$label = 'Disallowed field';
$edit1 = [
'new_storage_type' => 'test_field',
];
$edit2 = [
'label' => $label,
];
// Try with an entity key.
$edit2['field_name'] = 'title';
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
$this->drupalGet("{$bundle_path}/fields/add-field");
$this->submitForm($edit1, 'Continue');
$this->submitForm($edit2, 'Continue');
$this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.');
// Try with a base field.
$edit2['field_name'] = 'sticky';
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
$this->drupalGet("{$bundle_path}/fields/add-field");
$this->submitForm($edit1, 'Continue');
$this->submitForm($edit2, 'Continue');
$this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.');
}
/**
* Tests that Field UI respects locked fields.
*/
......@@ -242,9 +210,9 @@ public function testHiddenFields(): void {
}
/**
* Tests that a duplicate field name is caught by validation.
* Tests validation of duplicate and disallowed field names.
*/
public function testDuplicateFieldName(): void {
public function testFieldNameValidation(): void {
// field_tags already exists, so we're expecting an error when trying to
// create a new field with the same name.
$url = 'admin/structure/types/manage/' . $this->contentType . '/fields/add-field';
......@@ -259,14 +227,46 @@ public function testDuplicateFieldName(): void {
];
$this->submitForm($edit, 'Continue');
$this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.');
// Reset the field prefix so we can test properly.
$this->config('field_ui.settings')->set('field_prefix', '')->save();
$label = 'Disallowed field';
$edit1 = [
'new_storage_type' => 'test_field',
];
$edit2 = [
'label' => $label,
];
// Try with an entity key.
$edit2['field_name'] = 'title';
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
$this->drupalGet("{$bundle_path}/fields/add-field");
$this->submitForm($edit1, 'Continue');
$this->submitForm($edit2, 'Continue');
$this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.');
// Try with a base field.
$edit2['field_name'] = 'sticky';
$bundle_path = 'admin/structure/types/manage/' . $this->contentType;
$this->drupalGet("{$bundle_path}/fields/add-field");
$this->submitForm($edit1, 'Continue');
$this->submitForm($edit2, 'Continue');
$this->assertSession()->pageTextContains('The machine-readable name is already in use. It must be unique.');
$this->assertSession()->addressEquals($url);
}
/**
* Tests that external URLs in the 'destinations' query parameter are blocked.
* Tests invalid field UI URLs and destinations.
*/
public function testExternalDestinations(): void {
public function testInvalidUrlsAndDestinations(): void {
$field_id = 'node.foo.bar';
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
$this->assertSession()->statusCodeEquals(404);
$options = [
'query' => ['destinations' => ['http://example.com']],
];
......@@ -278,24 +278,6 @@ public function testExternalDestinations(): void {
$this->assertSession()->responseContains('Attempt to update field <em class="placeholder">Body</em> failed: <em class="placeholder">The internal path component &#039;http://example.com&#039; is external. You are not allowed to specify an external URL together with internal:/.</em>.');
}
/**
* Tests that deletion removes field storages and fields as expected for a term.
*/
public function testDeleteTaxonomyField(): void {
// Create a new field.
$bundle_path = 'admin/structure/taxonomy/manage/tags/overview';
$this->fieldUIAddNewField($bundle_path, $this->fieldNameInput, $this->fieldLabel);
// Delete the field.
$this->fieldUIDeleteField($bundle_path, "taxonomy_term.tags.$this->fieldName", $this->fieldLabel, 'Tags', 'taxonomy vocabulary');
// Check that the field was deleted.
$this->assertNull(FieldConfig::loadByName('taxonomy_term', 'tags', $this->fieldName), 'Field was deleted.');
// Check that the field storage was deleted too.
$this->assertNull(FieldStorageConfig::loadByName('taxonomy_term', $this->fieldName), 'Field storage was deleted.');
}
/**
* Tests that help descriptions render valid HTML.
*/
......@@ -374,16 +356,6 @@ public function testPreconfiguredFields(): void {
$this->assertEquals('altered dummy test string', $view_display->getComponent('field_test_custom_options')['settings']['test_formatter_setting_multiple']);
}
/**
* Tests the access to non-existent field URLs.
*/
public function testNonExistentFieldUrls(): void {
$field_id = 'node.foo.bar';
$this->drupalGet('admin/structure/types/manage/' . $this->contentType . '/fields/' . $field_id);
$this->assertSession()->statusCodeEquals(404);
}
/**
* Tests that the 'field_prefix' setting works on Field UI.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment