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

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

parent e71ddea0
No related branches found
No related tags found
20 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8736Update the Documention As per the Function uses.,!8513Issue #3453786: DefaultSelection should document why values for target_bundles NULL and [] behave as they do,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #250377 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.
Finish editing this message first!
Please register or to comment