Commit 71813a85 authored by catch's avatar catch
Browse files

Issue #3139407 by pavnish, mohrerao, mondrake, shaktik, rahulrasgon, durgeshs,...

Issue #3139407 by pavnish, mohrerao, mondrake, shaktik, rahulrasgon, durgeshs, shetpooja04, paulocs, ravi.shankar, ankithashetty, anmolgoyal74, munish.kumar, jungle, longwave, daffie: Replace usages of AssertLegacyTrait::assert(No)FieldById, that is deprecated
parent 95132eec
......@@ -205,7 +205,7 @@ public function testViewsBlockForm() {
$this->assertTrue(empty($elements), 'The label field is not found for Views blocks.');
// Test that the machine name field is hidden from display and has been
// saved as expected from the default value.
$this->assertNoFieldById('edit-machine-name', 'views_block__test_view_block_1', 'The machine name is hidden on the views block form.');
$this->assertSession()->fieldNotExists('edit-machine-name', NULL);
// Save the block.
$edit = ['region' => 'content'];
......
......@@ -231,12 +231,12 @@ public function testEditComment() {
// Make sure the comment field is not visible when
// the comment was posted by an authenticated user.
$this->drupalGet('comment/' . $comment->id() . '/edit');
$this->assertNoFieldById('edit-mail', $comment->getAuthorEmail());
$this->assertSession()->fieldNotExists('edit-mail');
// Make sure the comment field is visible when
// the comment was posted by an anonymous user.
$this->drupalGet('comment/' . $anonymous_comment->id() . '/edit');
$this->assertFieldById('edit-mail', $anonymous_comment->getAuthorEmail());
$this->assertSession()->fieldValueEquals('edit-mail', $anonymous_comment->getAuthorEmail());
}
/**
......
......@@ -48,7 +48,7 @@ protected function setUp(): void {
public function testExport() {
// Verify the export page with export submit button is available.
$this->drupalGet('admin/config/development/configuration/full/export');
$this->assertFieldById('edit-submit', t('Export'));
$this->assertSession()->buttonExists('Export');
// Submit the export form and verify response. This will create a file in
// temporary directory with the default name config.tar.gz.
......
......@@ -58,7 +58,7 @@ public function testImport() {
$this->drupalGet('admin/config/development/configuration');
$this->assertText('There are no configuration changes to import.');
$this->assertNoFieldById('edit-submit', t('Import all'));
$this->assertSession()->buttonNotExists('Import all');
// Create updated configuration object.
$new_site_name = 'Config import test ' . $this->randomString();
......@@ -126,7 +126,7 @@ public function testImport() {
$this->assertRaw('<td>core.extension');
$this->assertRaw('<td>system.theme');
$this->assertRaw('<td>automated_cron.settings');
$this->assertFieldById('edit-submit', t('Import all'));
$this->assertSession()->buttonExists('Import all');
// Import and verify that both do not appear anymore.
$this->drupalPostForm(NULL, [], t('Import all'));
......@@ -136,7 +136,7 @@ public function testImport() {
$this->assertNoRaw('<td>system.theme');
$this->assertNoRaw('<td>automated_cron.settings');
$this->assertNoFieldById('edit-submit', t('Import all'));
$this->assertSession()->buttonNotExists('Import all');
// Verify that there are no further changes to import.
$this->assertText(t('There are no configuration changes to import.'));
......@@ -269,7 +269,7 @@ public function testImportSiteUuidValidation() {
// Verify that there are configuration differences to import.
$this->drupalGet('admin/config/development/configuration');
$this->assertText(t('The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.'));
$this->assertNoFieldById('edit-submit', t('Import all'));
$this->assertSession()->buttonNotExists('Import all');
}
/**
......
......@@ -92,9 +92,9 @@ public function testLimitExposedOperators() {
// Because there are not operators that use the min and max fields, those
// fields should not be in the exposed form.
$this->assertFieldById('edit-field-date-value-value');
$this->assertNoFieldById('edit-field-date-value-min');
$this->assertNoFieldById('edit-field-date-value-max');
$this->assertSession()->fieldExists('edit-field-date-value-value');
$this->assertSession()->fieldNotExists('edit-field-date-value-min');
$this->assertSession()->fieldNotExists('edit-field-date-value-max');
$edit = [];
$edit['options[operator]'] = '>';
......@@ -110,9 +110,9 @@ public function testLimitExposedOperators() {
$this->assertSession()->optionExists('edit-field-date-value-op', '>');
$this->assertSession()->optionExists('edit-field-date-value-op', '>=');
$this->assertFieldById('edit-field-date-value-value');
$this->assertFieldById('edit-field-date-value-min');
$this->assertFieldById('edit-field-date-value-max');
$this->assertSession()->fieldExists('edit-field-date-value-value');
$this->assertSession()->fieldExists('edit-field-date-value-min');
$this->assertSession()->fieldExists('edit-field-date-value-max');
// Set the default to an excluded operator.
$edit = [];
......
......@@ -181,8 +181,8 @@ public function testBooleanField() {
// Test the boolean field settings.
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name);
$this->assertFieldById('edit-settings-on-label', $on);
$this->assertFieldById('edit-settings-off-label', $off);
$this->assertSession()->fieldValueEquals('edit-settings-on-label', $on);
$this->assertSession()->fieldValueEquals('edit-settings-off-label', $off);
}
/**
......
......@@ -437,7 +437,7 @@ public function assertSetMinimumValue($field, $minimum_value) {
$this->assertRaw(t('Saved %label configuration.', ['%label' => $field->getLabel()]));
// Check if the minimum value was actually set.
$this->drupalGet($field_configuration_url);
$this->assertFieldById('edit-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) . ' value was set on a ' . $field->getType() . ' field.');
$this->assertSession()->fieldValueEquals('edit-settings-min', $minimum_value);
}
}
......@@ -458,7 +458,7 @@ public function testDefaultValue() {
$element_id = "edit-default-value-input-$field_name-0-value";
$element_name = "default_value_input[{$field_name}][0][value]";
$this->drupalGet($admin_path);
$this->assertFieldById($element_id, '', 'The default value widget was empty.');
$this->assertSession()->fieldValueEquals($element_id, '');
// Check that invalid default values are rejected.
$edit = [$element_name => '-1'];
......@@ -474,7 +474,7 @@ public function testDefaultValue() {
// Check that the default value shows up in the form
$this->drupalGet($admin_path);
$this->assertFieldById($element_id, '1', 'The default value widget was displayed with the correct value.');
$this->assertSession()->fieldValueEquals($element_id, '1');
// Check that the default value can be emptied.
$edit = [$element_name => ''];
......@@ -506,7 +506,7 @@ public function testDefaultValue() {
->removeComponent($field_name)
->save();
$this->drupalGet($admin_path);
$this->assertFieldById($element_id, '', 'The default value widget was displayed when field is hidden.');
$this->assertSession()->fieldValueEquals($element_id, '');
}
/**
......
......@@ -37,8 +37,8 @@ public function testUIBrowserLanguageMappings() {
// Check that defaults are loaded from language.mappings.yml.
$this->drupalGet('admin/config/regional/language/detection/browser');
$this->assertFieldById('edit-mappings-zh-cn-browser-langcode', 'zh-cn');
$this->assertFieldById('edit-mappings-zh-cn-drupal-langcode', 'zh-hans');
$this->assertSession()->fieldValueEquals('edit-mappings-zh-cn-browser-langcode', 'zh-cn');
$this->assertSession()->fieldValueEquals('edit-mappings-zh-cn-drupal-langcode', 'zh-hans');
// Delete zh-cn language code.
$browser_langcode = 'zh-cn';
......@@ -70,8 +70,8 @@ public function testUIBrowserLanguageMappings() {
];
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
$this->assertSession()->addressEquals(Url::fromRoute('language.negotiation_browser'));
$this->assertFieldById('edit-mappings-xx-browser-langcode', 'xx');
$this->assertFieldById('edit-mappings-xx-drupal-langcode', 'en');
$this->assertSession()->fieldValueEquals('edit-mappings-xx-browser-langcode', 'xx');
$this->assertSession()->fieldValueEquals('edit-mappings-xx-drupal-langcode', 'en');
// Add the same custom mapping again.
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
......@@ -92,8 +92,8 @@ public function testUIBrowserLanguageMappings() {
];
$this->drupalPostForm('admin/config/regional/language/detection/browser', $edit, t('Save configuration'));
$this->assertSession()->addressEquals(Url::fromRoute('language.negotiation_browser'));
$this->assertFieldById('edit-mappings-xx-browser-langcode', 'xx');
$this->assertFieldById('edit-mappings-xx-drupal-langcode', 'zh-hans');
$this->assertSession()->fieldValueEquals('edit-mappings-xx-browser-langcode', 'xx');
$this->assertSession()->fieldValueEquals('edit-mappings-xx-drupal-langcode', 'zh-hans');
}
}
......@@ -205,7 +205,7 @@ public function testConfigTranslation() {
// Check if the UI does not show the translated String.
$this->drupalGet('admin/structure/contact/manage/feedback');
$this->assertFieldById('edit-label', 'Website feedback', 'Translation is not loaded for Edit Form.');
$this->assertSession()->fieldValueEquals('edit-label', 'Website feedback');
}
/**
......
......@@ -190,9 +190,9 @@ public function testMenuNodeFormWidget() {
// Assert that the link exists.
$this->drupalGet('test-page');
$this->assertSession()->linkExists($node_title);
// Check if menu weight is 17.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertFieldById('edit-menu-weight', 17, 'Menu weight correct in edit form');
$this->assertSession()->fieldValueEquals('edit-menu-weight', 17);
// Verify that the menu link title field has correct maxlength in node edit
// form.
$this->assertSession()->responseMatches('/<input .* id="edit-menu-title" .* maxlength="' . $title_max_length . '" .* \/>/');
......@@ -349,14 +349,14 @@ public function testMultilingualMenuNodeFormWidget() {
$options = ['language' => $languages[$langcodes[0]]];
$url = $node->toUrl('edit-form', $options);
$this->drupalGet($url);
$this->assertFieldById('edit-menu-title', $node_title);
$this->assertSession()->fieldValueEquals('edit-menu-title', $node_title);
$this->drupalPostForm(NULL, [], t('Save') . ' ' . t('(this translation)'));
// Revisit the edit page of the translation and check the loaded menu item title.
$options = ['language' => $languages[$langcodes[1]]];
$url = $node->toUrl('edit-form', $options);
$this->drupalGet($url);
$this->assertFieldById('edit-menu-title', $translated_node_title);
$this->assertSession()->fieldValueEquals('edit-menu-title', $translated_node_title);
}
}
......@@ -91,7 +91,7 @@ public function testNodeCreation() {
]);
$this->drupalLogin($admin_user);
$this->drupalGet('node/add/page');
$this->assertNoFieldById('edit-revision', NULL, 'The revision checkbox is not present.');
$this->assertSession()->fieldNotExists('edit-revision', NULL);
}
/**
......
......@@ -128,7 +128,7 @@ public function testNodeEdit() {
// Check if the node revision checkbox is rendered on node edit form.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertFieldById('edit-revision', NULL, 'The revision field is present.');
$this->assertSession()->fieldExists('edit-revision', NULL);
// Check that details form element opens when there are errors on child
// elements.
......
......@@ -177,8 +177,8 @@ protected function runRevisionsTests($entity_type) {
// Confirm the correct revision text appears in the edit form.
$entity = $storage->load($entity->id->value);
$this->drupalGet($entity_type . '/manage/' . $entity->id->value . '/edit');
$this->assertFieldById('edit-name-0-value', $entity->name->value, new FormattableMarkup('%entity_type: Name matches in UI.', ['%entity_type' => $entity_type]));
$this->assertFieldById('edit-translatable-test-field-0-value', $entity->translatable_test_field->value, new FormattableMarkup('%entity_type: Text matches in UI.', ['%entity_type' => $entity_type]));
$this->assertSession()->fieldValueEquals('edit-name-0-value', $entity->name->value);
$this->assertSession()->fieldValueEquals('edit-translatable-test-field-0-value', $entity->translatable_test_field->value);
}
/**
......
......@@ -121,7 +121,7 @@ public function testFilterUI() {
$display['display_options']['filters']['tid']['type'] = 'textfield';
$view->save();
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
$this->assertFieldById('edit-options-value', NULL);
$this->assertSession()->fieldExists('edit-options-value');
// Tests \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::calculateDependencies().
$expected = [
......
......@@ -76,8 +76,8 @@ public function testUserAdd() {
// Test user creation page for valid fields.
$this->drupalGet('admin/people/create');
$this->assertFieldbyId('edit-status-0', 0, 'The user status option Blocked exists.', 'User login');
$this->assertFieldbyId('edit-status-1', 1, 'The user status option Active exists.', 'User login');
$this->assertSession()->fieldValueEquals('edit-status-0', '1');
$this->assertSession()->fieldValueEquals('edit-status-1', '1');
$this->assertFieldByXPath('//input[@type="radio" and @id="edit-status-1" and @checked="checked"]', NULL, 'Default setting for user status is active.');
// Test that browser autocomplete behavior does not occur.
......
......@@ -56,12 +56,12 @@ public function testBulkForm() {
$first_form_element = $this->xpath('//form/div[1][@id = :id]', [':id' => 'edit-header']);
$this->assertNotEmpty($first_form_element, 'The views form edit header appears first.');
$this->assertFieldById('edit-action', NULL, 'The action select field appears.');
$this->assertSession()->fieldExists('edit-action');
// Make sure a checkbox appears on all rows.
$edit = [];
for ($i = 0; $i < 10; $i++) {
$this->assertFieldById('edit-node-bulk-form-' . $i, NULL, new FormattableMarkup('The checkbox on row @row appears.', ['@row' => $i]));
$this->assertSession()->fieldExists('edit-node-bulk-form-' . $i);
$edit["node_bulk_form[$i]"] = TRUE;
}
......
......@@ -115,7 +115,7 @@ public function testExposedIdentifier() {
]);
$view->save();
$this->drupalGet('test_exposed_form_buttons', ['query' => [$identifier => 'article']]);
$this->assertFieldById(Html::getId('edit-' . $identifier), 'article', "Article type filter set with new identifier.");
$this->assertSession()->fieldValueEquals(Html::getId('edit-' . $identifier), 'article');
// Alter the identifier of the filter to a random string containing
// restricted characters.
......@@ -160,13 +160,13 @@ public function testResetButton() {
$this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article']]);
// Test that the type has been set.
$this->assertFieldById('edit-type', 'article', 'Article type filter set.');
$this->assertSession()->fieldValueEquals('edit-type', 'article');
// Test the reset works.
$this->drupalGet('test_exposed_form_buttons', ['query' => ['op' => 'Reset']]);
$this->assertSession()->statusCodeEquals(200);
// Test the type has been reset.
$this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.');
$this->assertSession()->fieldValueEquals('edit-type', 'All');
// Test the button is hidden after reset.
$this->assertSession()->fieldNotExists('edit-reset');
......@@ -174,7 +174,7 @@ public function testResetButton() {
// Test the reset works with type set.
$this->drupalGet('test_exposed_form_buttons', ['query' => ['type' => 'article', 'op' => 'Reset']]);
$this->assertSession()->statusCodeEquals(200);
$this->assertFieldById('edit-type', 'All', 'Article type filter has been reset.');
$this->assertSession()->fieldValueEquals('edit-type', 'All');
// Test the button is hidden after reset.
$this->assertSession()->fieldNotExists('edit-reset');
......
......@@ -185,9 +185,9 @@ public function testLimitExposedOperators() {
// Because there are not operators that use the min and max fields, those
// fields should not be in the exposed form.
$this->assertFieldById('edit-nid-value');
$this->assertNoFieldById('edit-nid-min');
$this->assertNoFieldById('edit-nid-max');
$this->assertSession()->fieldExists('edit-nid-value');
$this->assertSession()->fieldNotExists('edit-nid-min');
$this->assertSession()->fieldNotExists('edit-nid-max');
$edit = [];
$edit['options[operator]'] = '>';
......@@ -203,9 +203,9 @@ public function testLimitExposedOperators() {
$this->assertSession()->optionExists('edit-nid-op', '>');
$this->assertSession()->optionExists('edit-nid-op', '>=');
$this->assertFieldById('edit-nid-value');
$this->assertFieldById('edit-nid-min');
$this->assertFieldById('edit-nid-max');
$this->assertSession()->fieldExists('edit-nid-value');
$this->assertSession()->fieldExists('edit-nid-min');
$this->assertSession()->fieldExists('edit-nid-max');
// Set the default to an excluded operator.
$edit = [];
......
......@@ -55,16 +55,16 @@ public function testCacheData() {
$this->drupalGet('admin/structure/views/view/test_view/edit');
// Test that save and cancel buttons are not shown.
$this->assertNoFieldById('edit-actions-submit', t('Save'));
$this->assertNoFieldById('edit-actions-cancel', t('Cancel'));
$this->assertSession()->buttonNotExists('Save');
$this->assertSession()->buttonNotExists('Cancel');
// Test we have the break lock link.
$this->assertSession()->linkByHrefExists('admin/structure/views/view/test_view/break-lock');
// Break the lock.
$this->clickLink(t('break this lock'));
$this->drupalPostForm(NULL, [], t('Break lock'));
// Test that save and cancel buttons are shown.
$this->assertFieldById('edit-actions-submit', t('Save'));
$this->assertFieldById('edit-actions-cancel', t('Cancel'));
$this->assertSession()->buttonExists('Save');
$this->assertSession()->buttonExists('Cancel');
// Test we can save the view.
$this->drupalPostForm('admin/structure/views/view/test_view/edit', [], t('Save'));
$this->assertRaw(t('The view %view has been saved.', ['%view' => 'Test view']));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment