diff --git a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php index a4c27db..d384ddd 100644 --- a/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php +++ b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php @@ -203,7 +203,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, 'The machine name is hidden on the views block form.'); // Save the block. $edit = ['region' => 'content']; diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php index 22c1fa7..cb5c56b 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -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', NULL, $comment->getAuthorEmail()); // 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()->fieldExists('edit-mail', NULL, $anonymous_comment->getAuthorEmail()); } /** diff --git a/core/modules/config/tests/src/Functional/ConfigExportUITest.php b/core/modules/config/tests/src/Functional/ConfigExportUITest.php index 32c9eae..76365ae 100644 --- a/core/modules/config/tests/src/Functional/ConfigExportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigExportUITest.php @@ -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()->fieldExists('edit-submit', NULL, t('Export')); // Submit the export form and verify response. This will create a file in // temporary directory with the default name config.tar.gz. diff --git a/core/modules/config/tests/src/Functional/ConfigImportUITest.php b/core/modules/config/tests/src/Functional/ConfigImportUITest.php index 82d0ede..3b0a2f8 100644 --- a/core/modules/config/tests/src/Functional/ConfigImportUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigImportUITest.php @@ -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()->fieldNotExists('edit-submit', NULL, t('Import all')); // Create updated configuration object. $new_site_name = 'Config import test ' . $this->randomString(); @@ -126,7 +126,7 @@ public function testImport() { $this->assertRaw('core.extension'); $this->assertRaw('system.theme'); $this->assertRaw('automated_cron.settings'); - $this->assertFieldById('edit-submit', t('Import all')); + $this->assertSession()->fieldExists('edit-submit', NULL, t('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('system.theme'); $this->assertNoRaw('automated_cron.settings'); - $this->assertNoFieldById('edit-submit', t('Import all')); + $this->assertSession()->fieldNotExists('edit-submit', NULL, t('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()->fieldNotExists('edit-submit', NULL, t('Import all')); } /** diff --git a/core/modules/datetime/tests/src/Functional/DateFilterTest.php b/core/modules/datetime/tests/src/Functional/DateFilterTest.php index 402cfba..843f109 100644 --- a/core/modules/datetime/tests/src/Functional/DateFilterTest.php +++ b/core/modules/datetime/tests/src/Functional/DateFilterTest.php @@ -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 = []; diff --git a/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php b/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php index b34504e..8e12b02 100644 --- a/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php +++ b/core/modules/field/tests/src/Functional/Boolean/BooleanFieldTest.php @@ -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()->fieldExists('edit-settings-on-label'); + $this->assertSession()->fieldExists('edit-settings-off-label'); } /** diff --git a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php index e4e9358..1975188 100644 --- a/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php +++ b/core/modules/field/tests/src/Functional/Number/NumberFieldTest.php @@ -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()->fieldExists('edit-settings-min', NULL, 'Minimal ' . gettype($minimum_value) . ' value was set on a ' . $field->getType() . ' field.'); } } diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php index 902857a..879e92d 100644 --- a/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php @@ -443,7 +443,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()->fieldExists($element_id, NULL, 'The default value widget was empty.'); // Check that invalid default values are rejected. $edit = [$element_name => '-1']; @@ -459,7 +459,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()->fieldExists($element_id, NULL, 'The default value widget was displayed with the correct value.'); // Check that the default value can be emptied. $edit = [$element_name => '']; @@ -491,7 +491,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()->fieldExists($element_id, NULL, 'The default value widget was displayed when field is hidden.'); } /** diff --git a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php index 9e2f53e..2734b16 100644 --- a/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php @@ -197,7 +197,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()->fieldExists('edit-label', NULL, 'Translation is not loaded for Edit Form.'); } /** diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php index 256f175..b357230 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php @@ -192,7 +192,7 @@ public function testMenuNodeFormWidget() { $this->assertLink($node_title); $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertFieldById('edit-menu-weight', 17, 'Menu weight correct in edit form'); + $this->assertSession()->fieldExists('edit-menu-weight', NULL, 'Menu weight correct in edit form'); $this->assertPattern('//', 'Menu link title field has correct maxlength in node edit form.'); $this->assertPattern('//', 'Menu link description field has correct maxlength in node add form.'); @@ -345,14 +345,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()->fieldExists('edit-menu-title', NULL, $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()->fieldExists('edit-menu-title', NULL, $translated_node_title); } } diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index c2685a5..6cea222 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -86,7 +86,7 @@ public function testNodeCreation() { $admin_user = $this->drupalCreateUser(['administer nodes', 'create page content']); $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, 'The revision checkbox is not present.'); } /** diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php index fea180f..44aec7c 100644 --- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php +++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php @@ -119,7 +119,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, 'The revision field is present.'); // Check that details form element opens when there are errors on child // elements. diff --git a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php index 90bf027..ea277cd 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php @@ -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()->fieldExists('edit-name-0-value', NULL, new FormattableMarkup('%entity_type: Name matches in UI.', ['%entity_type' => $entity_type])); + $this->assertSession()->fieldExists('edit-translatable-test-field-0-value', NULL, new FormattableMarkup('%entity_type: Text matches in UI.', ['%entity_type' => $entity_type])); } /** diff --git a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php index f9fbce2..af4998e 100644 --- a/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php @@ -118,7 +118,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', NULL); // Tests \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::calculateDependencies(). $expected = [ diff --git a/core/modules/user/tests/src/Functional/UserCreateTest.php b/core/modules/user/tests/src/Functional/UserCreateTest.php index fef1a53..06d1a23 100644 --- a/core/modules/user/tests/src/Functional/UserCreateTest.php +++ b/core/modules/user/tests/src/Functional/UserCreateTest.php @@ -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()->fieldExists('edit-status-0', NULL, 'The user status option Blocked exists.', 'User login'); + $this->assertSession()->fieldExists('edit-status-1', NULL, 'The user status option Active exists.', 'User login'); $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. diff --git a/core/modules/views/tests/src/Functional/BulkFormTest.php b/core/modules/views/tests/src/Functional/BulkFormTest.php index 224dc9f..c47196e 100644 --- a/core/modules/views/tests/src/Functional/BulkFormTest.php +++ b/core/modules/views/tests/src/Functional/BulkFormTest.php @@ -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', NULL, 'The action select field appears.'); // 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, NULL, new FormattableMarkup('The checkbox on row @row appears.', ['@row' => $i])); $edit["node_bulk_form[$i]"] = TRUE; } diff --git a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php index d5b0ce8..11ea22d 100644 --- a/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php @@ -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()->fieldExists(Html::getId('edit-' . $identifier), NULL, "Article type filter set with new identifier."); // 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()->fieldExists('edit-type', NULL, 'Article type filter set.'); // 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()->fieldExists('edit-type', NULL, 'Article type filter has been reset.'); // Test the button is hidden after reset. $this->assertNoField('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()->fieldExists('edit-type', NULL, 'Article type filter has been reset.'); // Test the button is hidden after reset. $this->assertNoField('edit-reset'); diff --git a/core/modules/views/tests/src/Functional/Plugin/FilterTest.php b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php index 393d602..2b552ab 100644 --- a/core/modules/views/tests/src/Functional/Plugin/FilterTest.php +++ b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php @@ -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 = []; diff --git a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php index e50005f..24a2a67 100644 --- a/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php +++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php @@ -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()->fieldNotExists('edit-actions-submit', NULL, t('Save')); + $this->assertSession()->fieldNotExists('edit-actions-cancel', NULL, t('Cancel')); // Test we have the break lock link. $this->assertLinkByHref('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()->fieldExists('edit-actions-submit', NULL, t('Save')); + $this->assertSession()->fieldExists('edit-actions-cancel', NULL, t('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'])); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php index bcbf4b7..ac01259 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php @@ -85,7 +85,7 @@ public function testRemoveAttachedDisplay() { // Open the Page display and mark it as deleted. $this->drupalGet($path_prefix . '/page_1'); - $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display.'); + $this->assertSession()->fieldExists('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', NULL, 'Make sure there is a delete button on the page display.'); $this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page'); // Open the attachment display and save it. diff --git a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php index 3ab3c38..fc8ecf8 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php @@ -62,14 +62,14 @@ public function testRemoveDisplay() { $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit'; $this->drupalGet($path_prefix . '/default'); - $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is no delete button on the default display.'); + $this->assertSession()->fieldNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', NULL, 'Make sure there is no delete button on the default display.'); $this->drupalGet($path_prefix . '/page_1'); - $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display.'); + $this->assertSession()->fieldExists('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', NULL, 'Make sure there is a delete button on the page display.'); // Delete the page, so we can test the undo process. $this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page'); - $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there a undo button on the page display after deleting.'); + $this->assertSession()->fieldExists('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', NULL, 'Make sure there a undo button on the page display after deleting.'); $element = $this->xpath('//a[contains(@href, :href) and contains(@class, :class)]', [':href' => $path_prefix . '/page_1', ':class' => 'views-display-deleted-link']); $this->assertTrue(!empty($element), 'Make sure the display link is marked as to be deleted.'); @@ -78,8 +78,8 @@ public function testRemoveDisplay() { // Undo the deleting of the display. $this->drupalPostForm($path_prefix . '/page_1', [], 'Undo delete of Page'); - $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', 'Undo delete of Page', 'Make sure there is no undo button on the page display after reverting.'); - $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', 'Delete Page', 'Make sure there is a delete button on the page display after the reverting.'); + $this->assertSession()->fieldNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete', NULL, 'Make sure there is no undo button on the page display after reverting.'); + $this->assertSession()->fieldExists('edit-displays-settings-settings-content-tab-content-details-top-actions-delete', NULL, 'Make sure there is a delete button on the page display after the reverting.'); // Now delete again and save the view. $this->drupalPostForm($path_prefix . '/page_1', [], 'Delete Page'); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayTest.php b/core/modules/views_ui/tests/src/Functional/DisplayTest.php index de7824a..2dde457 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php @@ -90,13 +90,13 @@ public function testDisableDisplay() { $this->drupalGet($path_prefix); $this->assertEmpty($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appear after initial adding of a view.'); - $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is visible.'); - $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is not visible.'); + $this->assertSession()->fieldExists('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is visible.'); + $this->assertSession()->fieldNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is not visible.'); $this->drupalPostForm(NULL, [], 'Disable Page'); $this->assertNotEmpty($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class appears once the display is marked as such.'); - $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is not visible.'); - $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is visible.'); + $this->assertSession()->fieldNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is not visible.'); + $this->assertSession()->fieldExists('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is visible.'); $this->drupalPostForm(NULL, [], 'Enable Page'); $this->assertEmpty($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appears once the display is enabled again.'); } diff --git a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php index 28eef97..2d77fcd 100644 --- a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -73,10 +73,10 @@ public function testExposedAdminUi() { // The first time the filter UI is displayed, the operator and the // value forms should be shown. - $this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists'); - $this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists'); - $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists'); - $this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists'); + $this->assertSession()->fieldExists('edit-options-operator-in', NULL, 'Operator In exists'); + $this->assertSession()->fieldExists('edit-options-operator-not-in', NULL, 'Operator Not In exists'); + $this->assertSession()->fieldExists('edit-options-value-page', NULL, 'Checkbox for Page exists'); + $this->assertSession()->fieldExists('edit-options-value-article', NULL, 'Checkbox for Article exists'); // Click the Expose filter button. $this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter')); @@ -84,10 +84,10 @@ public function testExposedAdminUi() { $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter')); // After exposing the filter, Operator and Value should be still here. - $this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists'); - $this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists'); - $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists'); - $this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists'); + $this->assertSession()->fieldExists('edit-options-operator-in', NULL, 'Operator In exists'); + $this->assertSession()->fieldExists('edit-options-operator-not-in', NULL, 'Operator Not In exists'); + $this->assertSession()->fieldExists('edit-options-value-page', NULL, 'Checkbox for Page exists'); + $this->assertSession()->fieldExists('edit-options-value-article', NULL, 'Checkbox for Article exists'); // Check the validations of the filter handler. $edit = []; @@ -103,24 +103,24 @@ public function testExposedAdminUi() { // Now check the sort criteria. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created'); $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose sort')); - $this->assertNoFieldById('edit-options-expose-label', '', 'Make sure no label field is shown'); + $this->assertSession()->fieldNotExists('edit-options-expose-label', NULL, 'Make sure no label field is shown'); // Un-expose the filter. $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type'); $this->drupalPostForm(NULL, [], t('Hide filter')); // After Un-exposing the filter, Operator and Value should be shown again. - $this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists after hide filter'); - $this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists after hide filter'); - $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists after hide filter'); - $this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists after hide filter'); + $this->assertSession()->fieldExists('edit-options-operator-in', NULL, 'Operator In exists after hide filter'); + $this->assertSession()->fieldExists('edit-options-operator-not-in', NULL, 'Operator Not In exists after hide filter'); + $this->assertSession()->fieldExists('edit-options-value-page', NULL, 'Checkbox for Page exists after hide filter'); + $this->assertSession()->fieldExists('edit-options-value-article', NULL, 'Checkbox for Article exists after hide filter'); // Click the Expose sort button. $edit = []; $this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort')); // Check the label of the expose button. $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort')); - $this->assertFieldById('edit-options-expose-label', 'Authored on', 'Make sure a label field is shown'); + $this->assertSession()->fieldExists('edit-options-expose-label', NULL, 'Authored on', 'Make sure a label field is shown'); // Test adding a new exposed sort criteria. $view_id = $this->randomView()['id']; @@ -162,10 +162,10 @@ public function testGroupedFilterAdminUi() { // After click on 'Grouped Filters', the standard operator and value should // not be displayed. - $this->assertNoFieldById('edit-options-operator-in', 'in', 'Operator In not exists'); - $this->assertNoFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In not exists'); - $this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists'); - $this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists'); + $this->assertSession()->fieldNotExists('edit-options-operator-in', NULL, 'Operator In not exists'); + $this->assertSession()->fieldNotExists('edit-options-operator-not-in', NULL, 'Operator Not In not exists'); + $this->assertSession()->fieldNotExists('edit-options-value-page', NULL, 'Checkbox for Page not exists'); + $this->assertSession()->fieldNotExists('edit-options-value-article', NULL, 'Checkbox for Article not exists'); // Check that after click on 'Grouped Filters', a new button is shown to // add more items to the list. diff --git a/core/modules/views_ui/tests/src/Functional/SettingsTest.php b/core/modules/views_ui/tests/src/Functional/SettingsTest.php index 6c16a7e..4a0ee7e 100644 --- a/core/modules/views_ui/tests/src/Functional/SettingsTest.php +++ b/core/modules/views_ui/tests/src/Functional/SettingsTest.php @@ -89,7 +89,7 @@ public function testEditUI() { $view['id'] = strtolower($this->randomMachineName()); $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); - $this->assertFieldById('edit-displays-top-add-display-embed', NULL); + $this->assertSession()->fieldExists('edit-displays-top-add-display-embed'); $edit = [ 'ui_show_display_embed' => FALSE, @@ -97,7 +97,7 @@ public function testEditUI() { $this->drupalPostForm('admin/structure/views/settings', $edit, t('Save configuration')); $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); - $this->assertNoFieldById('edit-displays-top-add-display-embed'); + $this->assertSession()->fieldNotExists('edit-displays-top-add-display-embed'); // Configure to hide/show the sql at the preview. $edit = [