diff --git a/core/modules/block/tests/src/Functional/BlockTest.php b/core/modules/block/tests/src/Functional/BlockTest.php index 8aec3b2741f1..a0deb4d4572a 100644 --- a/core/modules/block/tests/src/Functional/BlockTest.php +++ b/core/modules/block/tests/src/Functional/BlockTest.php @@ -42,13 +42,13 @@ class BlockTest extends BlockTestBase { $edit['visibility[request_path][negate]'] = TRUE; $edit['visibility[user_role][roles][' . RoleInterface::AUTHENTICATED_ID . ']'] = TRUE; $this->drupalGet('admin/structure/block/add/' . $block_name . '/' . $default_theme); - $this->assertFieldChecked('edit-visibility-request-path-negate-0'); + $this->assertSession()->checkboxChecked('edit-visibility-request-path-negate-0'); $this->drupalPostForm(NULL, $edit, t('Save block')); $this->assertText('The block configuration has been saved.', 'Block was saved'); $this->clickLink('Configure'); - $this->assertFieldChecked('edit-visibility-request-path-negate-1'); + $this->assertSession()->checkboxChecked('edit-visibility-request-path-negate-1'); $this->drupalGet(''); $this->assertText($title, 'Block was displayed on the front page.'); @@ -85,14 +85,14 @@ class BlockTest extends BlockTestBase { $edit['visibility[user_role][roles][' . RoleInterface::AUTHENTICATED_ID . ']'] = TRUE; $this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block')); $this->clickLink('Configure'); - $this->assertFieldChecked('edit-visibility-user-role-roles-authenticated'); + $this->assertSession()->checkboxChecked('edit-visibility-user-role-roles-authenticated'); $edit = [ 'visibility[user_role][roles][' . RoleInterface::AUTHENTICATED_ID . ']' => FALSE, ]; $this->drupalPostForm(NULL, $edit, 'Save block'); $this->clickLink('Configure'); - $this->assertNoFieldChecked('edit-visibility-user-role-roles-authenticated'); + $this->assertSession()->checkboxNotChecked('edit-visibility-user-role-roles-authenticated'); // Ensure that no visibility is configured. /** @var \Drupal\block\BlockInterface $block */ @@ -316,7 +316,7 @@ class BlockTest extends BlockTestBase { $this->assertText('The block configuration has been saved.', 'Block was saved'); $this->drupalGet('admin/structure/block/manage/' . $id); - $this->assertFieldChecked('edit-settings-label-display', 'The display_block option has the correct default value on the configuration form.'); + $this->assertSession()->checkboxChecked('edit-settings-label-display'); $this->drupalGet('user'); $this->assertText($title, 'Block title was displayed when enabled.'); diff --git a/core/modules/comment/tests/src/Functional/CommentAdminTest.php b/core/modules/comment/tests/src/Functional/CommentAdminTest.php index 22c1fa748f8b..6036924f5488 100644 --- a/core/modules/comment/tests/src/Functional/CommentAdminTest.php +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php @@ -165,7 +165,7 @@ class CommentAdminTest extends CommentTestBase { // Approve comment. $this->drupalGet('comment/1/edit'); - $this->assertFieldChecked('edit-status-0'); + $this->assertSession()->checkboxChecked('edit-status-0'); $this->drupalGet('node/' . $this->node->id()); $this->clickLink(t('Approve')); $this->drupalLogout(); diff --git a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php index f436335e0a0d..8023bd204fbe 100644 --- a/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentNonNodeTest.php @@ -403,9 +403,9 @@ class CommentNonNodeTest extends BrowserTestBase { ]); $this->drupalLogin($limited_user); $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); - $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); - $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1'); - $this->assertFieldChecked('edit-default-value-input-comment-0-status-2'); + $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-0'); + $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-1'); + $this->assertSession()->checkboxChecked('edit-default-value-input-comment-0-status-2'); // Test comment option change in field settings. $edit = [ 'default_value_input[comment][0][status]' => CommentItemInterface::CLOSED, @@ -413,9 +413,9 @@ class CommentNonNodeTest extends BrowserTestBase { ]; $this->drupalPostForm(NULL, $edit, t('Save settings')); $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); - $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); - $this->assertFieldChecked('edit-default-value-input-comment-0-status-1'); - $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-2'); + $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-0'); + $this->assertSession()->checkboxChecked('edit-default-value-input-comment-0-status-1'); + $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-2'); $this->assertFieldByName('settings[anonymous]', CommentInterface::ANONYMOUS_MAY_CONTACT); // Add a new comment-type. @@ -448,8 +448,8 @@ class CommentNonNodeTest extends BrowserTestBase { $new_entity = EntityTest::create($data); $new_entity->save(); $this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit'); - $this->assertNoFieldChecked('edit-field-foobar-0-status-1'); - $this->assertFieldChecked('edit-field-foobar-0-status-2'); + $this->assertSession()->checkboxNotChecked('edit-field-foobar-0-status-1'); + $this->assertSession()->checkboxChecked('edit-field-foobar-0-status-2'); $this->assertNoField('edit-field-foobar-0-status-0'); // @todo Check proper url and form https://www.drupal.org/node/2458323 diff --git a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php index da19685e17e7..32b7588f7b0d 100644 --- a/core/modules/contact/tests/src/Functional/ContactPersonalTest.php +++ b/core/modules/contact/tests/src/Functional/ContactPersonalTest.php @@ -222,10 +222,10 @@ class ContactPersonalTest extends BrowserTestBase { // Test enabling and disabling the contact page through the user profile // form. $this->drupalGet('user/' . $this->webUser->id() . '/edit'); - $this->assertNoFieldChecked('edit-contact--2'); + $this->assertSession()->checkboxNotChecked('edit-contact--2'); $this->assertNull(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form disabled'); $this->drupalPostForm(NULL, ['contact' => TRUE], t('Save')); - $this->assertFieldChecked('edit-contact--2'); + $this->assertSession()->checkboxChecked('edit-contact--2'); $this->assertNotEmpty(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form enabled'); // Test with disabled global default contact form in combination with a user @@ -288,10 +288,10 @@ class ContactPersonalTest extends BrowserTestBase { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/people/create'); if ($this->config('contact.settings')->get('user_default_enabled', TRUE)) { - $this->assertFieldChecked('edit-contact--2'); + $this->assertSession()->checkboxChecked('edit-contact--2'); } else { - $this->assertNoFieldChecked('edit-contact--2'); + $this->assertSession()->checkboxNotChecked('edit-contact--2'); } $name = $this->randomMachineName(); $edit = [ diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php index deda601b424c..8d6a311024c7 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationEntityBundleUITest.php @@ -48,7 +48,7 @@ class ContentTranslationEntityBundleUITest extends BrowserTestBase { // Make sure add page does not inherit translation configuration from first // content type. $this->drupalGet('admin/structure/types/add'); - $this->assertNoFieldChecked('edit-language-configuration-content-translation'); + $this->assertSession()->checkboxNotChecked('edit-language-configuration-content-translation'); // Create second content type and set content translation. $edit = [ @@ -60,7 +60,7 @@ class ContentTranslationEntityBundleUITest extends BrowserTestBase { // Make sure the settings are saved when creating the content type. $this->drupalGet('admin/structure/types/manage/page'); - $this->assertFieldChecked('edit-language-configuration-content-translation'); + $this->assertSession()->checkboxChecked('edit-language-configuration-content-translation'); } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php index 6b0771cc298f..05e223dfe445 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php @@ -158,7 +158,7 @@ class ContentTranslationSettingsTest extends BrowserTestBase { // Verify language widget appears on comment type form. $this->drupalGet('admin/structure/comment/manage/comment_article'); $this->assertField('language_configuration[content_translation]'); - $this->assertFieldChecked('edit-language-configuration-content-translation'); + $this->assertSession()->checkboxChecked('edit-language-configuration-content-translation'); // Verify that translation may be enabled for the article content type. $edit = [ @@ -167,10 +167,10 @@ class ContentTranslationSettingsTest extends BrowserTestBase { // Make sure the checkbox is available and not checked by default. $this->drupalGet('admin/structure/types/manage/article'); $this->assertField('language_configuration[content_translation]'); - $this->assertNoFieldChecked('edit-language-configuration-content-translation'); + $this->assertSession()->checkboxNotChecked('edit-language-configuration-content-translation'); $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); $this->drupalGet('admin/structure/types/manage/article'); - $this->assertFieldChecked('edit-language-configuration-content-translation'); + $this->assertSession()->checkboxChecked('edit-language-configuration-content-translation'); // Test that the title field of nodes is available in the settings form. $edit = [ @@ -228,14 +228,14 @@ class ContentTranslationSettingsTest extends BrowserTestBase { // Make sure the checkbox is available and not checked by default. $this->drupalGet('admin/config/people/accounts'); $this->assertField('language[content_translation]'); - $this->assertNoFieldChecked('edit-language-content-translation'); + $this->assertSession()->checkboxNotChecked('edit-language-content-translation'); $edit = [ 'language[content_translation]' => TRUE, ]; $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); $this->drupalGet('admin/config/people/accounts'); - $this->assertFieldChecked('edit-language-content-translation'); + $this->assertSession()->checkboxChecked('edit-language-content-translation'); // Make sure account settings can be saved. $this->drupalPostForm('admin/config/people/accounts', ['anonymous' => 'Save me please!'], 'Save configuration'); diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationSyncImageTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationSyncImageTest.php index 0b88df350d3f..14c72d3ee952 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationSyncImageTest.php @@ -103,8 +103,8 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase { // Check that the alt and title fields are enabled for the image field. $this->drupalLogin($this->editor); $this->drupalGet('entity_test_mul/structure/' . $this->entityTypeId . '/fields/' . $this->entityTypeId . '.' . $this->entityTypeId . '.' . $this->fieldName); - $this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-alt'); - $this->assertFieldChecked('edit-third-party-settings-content-translation-translation-sync-title'); + $this->assertSession()->checkboxChecked('edit-third-party-settings-content-translation-translation-sync-alt'); + $this->assertSession()->checkboxChecked('edit-third-party-settings-content-translation-translation-sync-title'); $edit = [ 'third_party_settings[content_translation][translation_sync][alt]' => FALSE, 'third_party_settings[content_translation][translation_sync][title]' => FALSE, @@ -114,8 +114,8 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase { // Check that the content translation settings page reflects the changes // performed in the field edit page. $this->drupalGet('admin/config/regional/content-language'); - $this->assertNoFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt'); - $this->assertNoFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title'); + $this->assertSession()->checkboxNotChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt'); + $this->assertSession()->checkboxNotChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title'); $edit = [ 'settings[entity_test_mul][entity_test_mul][fields][field_test_et_ui_image]' => TRUE, 'settings[entity_test_mul][entity_test_mul][columns][field_test_et_ui_image][alt]' => TRUE, @@ -124,8 +124,8 @@ class ContentTranslationSyncImageTest extends ContentTranslationTestBase { $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration')); $errors = $this->xpath('//div[contains(@class, "messages--error")]'); $this->assertEmpty($errors, 'Settings correctly stored.'); - $this->assertFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt'); - $this->assertFieldChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title'); + $this->assertSession()->checkboxChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt'); + $this->assertSession()->checkboxChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title'); $this->drupalLogin($this->translator); $default_langcode = $this->langcodes[0]; diff --git a/core/modules/field/tests/src/Functional/Views/FieldUITest.php b/core/modules/field/tests/src/Functional/Views/FieldUITest.php index ea7506780b08..4ed44e31ea25 100644 --- a/core/modules/field/tests/src/Functional/Views/FieldUITest.php +++ b/core/modules/field/tests/src/Functional/Views/FieldUITest.php @@ -160,7 +160,7 @@ class FieldUITest extends FieldTestBase { $this->drupalPostForm(NULL, ['options[value]' => 'All', 'options[expose][required]' => FALSE], 'Apply'); $this->drupalPostForm(NULL, [], 'Save'); $this->drupalGet('/admin/structure/views/nojs/handler/test_view_fieldapi/default/filter/field_boolean_value'); - $this->assertFieldChecked('edit-options-value-all'); + $this->assertSession()->checkboxChecked('edit-options-value-all'); } } diff --git a/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php index 0424c164cb2d..2ff5950c92f6 100644 --- a/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php @@ -58,7 +58,7 @@ class LanguageConfigurationElementTest extends BrowserTestBase { $this->assertFalse($lang_conf->isLanguageAlterable()); $this->drupalGet('language-tests/language_configuration_element'); $this->assertTrue($this->assertSession()->optionExists('edit-lang-configuration-langcode', 'current_interface')->isSelected()); - $this->assertNoFieldChecked('edit-lang-configuration-language-alterable'); + $this->assertSession()->checkboxNotChecked('edit-lang-configuration-language-alterable'); // Reload the page and save again. $this->drupalGet('language-tests/language_configuration_element'); @@ -72,7 +72,7 @@ class LanguageConfigurationElementTest extends BrowserTestBase { $this->assertTrue($lang_conf->isLanguageAlterable()); $this->drupalGet('language-tests/language_configuration_element'); $this->assertTrue($this->assertSession()->optionExists('edit-lang-configuration-langcode', 'authors_default')->isSelected()); - $this->assertFieldChecked('edit-lang-configuration-language-alterable'); + $this->assertSession()->checkboxChecked('edit-lang-configuration-language-alterable'); // Test if content type settings have been saved. $edit = [ @@ -86,7 +86,7 @@ class LanguageConfigurationElementTest extends BrowserTestBase { // Make sure the settings are saved when creating the content type. $this->drupalGet('admin/structure/types/manage/page'); $this->assertTrue($this->assertSession()->optionExists('edit-language-configuration-langcode', 'authors_default')->isSelected()); - $this->assertFieldChecked('edit-language-configuration-language-alterable'); + $this->assertSession()->checkboxChecked('edit-language-configuration-language-alterable'); } diff --git a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php index 23d27740d436..f316f44b3cac 100644 --- a/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php @@ -70,7 +70,7 @@ class LanguageConfigurationTest extends BrowserTestBase { // Check if we can change the default language. $this->drupalGet('admin/config/regional/language'); - $this->assertFieldChecked('edit-site-default-language-en', 'English is the default language.'); + $this->assertSession()->checkboxChecked('edit-site-default-language-en'); // Change the default language. $edit = [ @@ -78,7 +78,7 @@ class LanguageConfigurationTest extends BrowserTestBase { ]; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->rebuildContainer(); - $this->assertFieldChecked('edit-site-default-language-fr', 'Default language updated.'); + $this->assertSession()->checkboxChecked('edit-site-default-language-fr'); $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'langcode' => 'fr'])->toString(), [], 'Correct page redirection.'); // Check if a valid language prefix is added after changing the default diff --git a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php index ecb68668cbac..235e09ad0c27 100644 --- a/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php @@ -47,7 +47,7 @@ class LanguageCustomLanguageConfigurationTest extends BrowserTestBase { $this->assertText(t('@name field is required.', ['@name' => t('Language code')])); $this->assertText(t('@name field is required.', ['@name' => t('Language name')])); $empty_language = new Language(); - $this->assertFieldChecked('edit-direction-' . $empty_language->getDirection(), 'Consistent usage of language direction.'); + $this->assertSession()->checkboxChecked('edit-direction-' . $empty_language->getDirection()); $this->assertUrl(Url::fromRoute('language.add', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.'); // Test validation of invalid values. diff --git a/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php index 80d839f6b672..9f3205ec1a40 100644 --- a/core/modules/language/tests/src/Functional/LanguageListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageListTest.php @@ -79,14 +79,14 @@ class LanguageListTest extends BrowserTestBase { // Check if we can change the default language. $path = 'admin/config/regional/language'; $this->drupalGet($path); - $this->assertFieldChecked('edit-site-default-language-en', 'English is the default language.'); + $this->assertSession()->checkboxChecked('edit-site-default-language-en'); // Change the default language. $edit = [ 'site_default_language' => $langcode, ]; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->rebuildContainer(); - $this->assertNoFieldChecked('edit-site-default-language-en', 'Default language updated.'); + $this->assertSession()->checkboxNotChecked('edit-site-default-language-en'); $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $language])->toString()); // Ensure we can't delete the default language. @@ -164,14 +164,14 @@ class LanguageListTest extends BrowserTestBase { // Check if we can change the default language. $path = 'admin/config/regional/language'; $this->drupalGet($path); - $this->assertFieldChecked('edit-site-default-language-en', 'English is the default language.'); + $this->assertSession()->checkboxChecked('edit-site-default-language-en'); // Change the default language. $edit = [ 'site_default_language' => $langcode, ]; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->rebuildContainer(); - $this->assertNoFieldChecked('edit-site-default-language-en', 'Default language updated.'); + $this->assertSession()->checkboxNotChecked('edit-site-default-language-en'); $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE, 'language' => $language])->toString()); $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete')); @@ -200,7 +200,7 @@ class LanguageListTest extends BrowserTestBase { $this->drupalPostForm(NULL, ['site_default_language' => 'nl'], 'Save configuration'); $this->assertText(t('Selected default language no longer exists.')); - $this->assertNoFieldChecked('edit-site-default-language-xx', 'The previous default language got deselected.'); + $this->assertSession()->checkboxNotChecked('edit-site-default-language-xx'); } /** diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php index dc444ce786fa..6c30e43372a7 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiTest.php @@ -502,8 +502,8 @@ class MenuUiTest extends BrowserTestBase { $this->assertFieldByName('title[0][value]', ''); $this->assertFieldByName('link[0][uri]', ''); - $this->assertNoFieldChecked('edit-expanded-value'); - $this->assertFieldChecked('edit-enabled-value'); + $this->assertSession()->checkboxNotChecked('edit-expanded-value'); + $this->assertSession()->checkboxChecked('edit-enabled-value'); $this->assertFieldByName('description[0][value]', ''); $this->assertFieldByName('weight[0][value]', 0); diff --git a/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php index 5e49d08accb9..6b398206325f 100644 --- a/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php +++ b/core/modules/node/tests/src/Functional/MultiStepNodeFormBasicOptionsTest.php @@ -65,8 +65,8 @@ class MultiStepNodeFormBasicOptionsTest extends NodeTestBase { "{$this->fieldName}[0][value]" => $this->randomString(32), ]; $this->drupalPostForm('node/add/page', $edit, t('Add another item')); - $this->assertNoFieldChecked('edit-promote-value', 'Promote stayed unchecked'); - $this->assertFieldChecked('edit-sticky-value', 'Sticky stayed checked'); + $this->assertSession()->checkboxNotChecked('edit-promote-value'); + $this->assertSession()->checkboxChecked('edit-sticky-value'); } } diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php index 37fff0c12225..049afb4db2f0 100644 --- a/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php +++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiBypassAccessTest.php @@ -68,7 +68,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase { // Verify the checkbox is checked on the node edit form. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); + $this->assertSession()->checkboxChecked('edit-revision'); // Uncheck the create new revision checkbox and save the node. $edit = ['revision' => FALSE]; @@ -80,7 +80,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase { // Verify the checkbox is checked on the node edit form. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); + $this->assertSession()->checkboxChecked('edit-revision'); // Submit the form without changing the checkbox. $edit = []; @@ -100,7 +100,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase { // Verify the checkbox is unchecked on the node edit form. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertNoFieldChecked('edit-revision', "'Create new revision' checkbox is unchecked"); + $this->assertSession()->checkboxNotChecked('edit-revision'); // Submit the form without changing the checkbox. $edit = []; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save'); @@ -112,7 +112,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase { // Verify the checkbox is unchecked on the node edit form. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertNoFieldChecked('edit-revision', "'Create new revision' checkbox is unchecked"); + $this->assertSession()->checkboxNotChecked('edit-revision'); // Check the 'create new revision' checkbox and save the node. $edit = ['revision' => TRUE]; diff --git a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php index 75e2cb1e68cf..9ebcaf31114a 100644 --- a/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php +++ b/core/modules/node/tests/src/Functional/NodeRevisionsUiTest.php @@ -57,7 +57,7 @@ class NodeRevisionsUiTest extends NodeTestBase { // Verify the checkbox is checked on the node edit form. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); + $this->assertSession()->checkboxChecked('edit-revision'); // Uncheck the create new revision checkbox and save the node. $edit = ['revision' => FALSE]; @@ -70,7 +70,7 @@ class NodeRevisionsUiTest extends NodeTestBase { // Verify the checkbox is checked on the node edit form. $this->drupalGet('node/' . $node->id() . '/edit'); - $this->assertFieldChecked('edit-revision', "'Create new revision' checkbox is checked"); + $this->assertSession()->checkboxChecked('edit-revision'); // Submit the form without changing the checkbox. $edit = []; diff --git a/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php b/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php index 6ba3f5f26060..c415307e35e5 100644 --- a/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypeInitialLanguageTest.php @@ -46,7 +46,7 @@ class NodeTypeInitialLanguageTest extends NodeTestBase { public function testNodeTypeInitialLanguageDefaults() { $this->drupalGet('admin/structure/types/manage/article'); $this->assertTrue($this->assertSession()->optionExists('edit-language-configuration-langcode', LanguageInterface::LANGCODE_SITE_DEFAULT)->isSelected()); - $this->assertNoFieldChecked('edit-language-configuration-language-alterable', 'Language selector is hidden by default.'); + $this->assertSession()->checkboxNotChecked('edit-language-configuration-language-alterable'); // Tests if the language field cannot be rearranged on the manage fields tab. $this->drupalGet('admin/structure/types/manage/article/fields'); diff --git a/core/modules/node/tests/src/Functional/PagePreviewTest.php b/core/modules/node/tests/src/Functional/PagePreviewTest.php index 7650fd694552..77b449a71f1e 100644 --- a/core/modules/node/tests/src/Functional/PagePreviewTest.php +++ b/core/modules/node/tests/src/Functional/PagePreviewTest.php @@ -408,7 +408,7 @@ class PagePreviewTest extends NodeTestBase { ]; $this->drupalPostForm(NULL, $edit, t('Preview')); $this->clickLink(t('Back to content editing')); - $this->assertFieldChecked('edit-menu-enabled', 'Menu option is still checked'); + $this->assertSession()->checkboxChecked('edit-menu-enabled'); $this->assertFieldByName('menu[title]', 'Changed title', 'Menu link title is correct after preview'); // Save, change the title while saving and make sure that it is correctly diff --git a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php index 538b5c4a8ab1..1b3511fa723a 100644 --- a/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php +++ b/core/modules/options/tests/src/Functional/OptionsWidgetsTest.php @@ -145,9 +145,9 @@ class OptionsWidgetsTest extends FieldTestBase { // With no field data, no buttons are checked. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); - $this->assertNoFieldChecked('edit-card-1-0'); - $this->assertNoFieldChecked('edit-card-1-1'); - $this->assertNoFieldChecked('edit-card-1-2'); + $this->assertSession()->checkboxNotChecked('edit-card-1-0'); + $this->assertSession()->checkboxNotChecked('edit-card-1-1'); + $this->assertSession()->checkboxNotChecked('edit-card-1-2'); $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); $this->assertRaw('Some HTML encoded markup with < & >'); @@ -158,9 +158,9 @@ class OptionsWidgetsTest extends FieldTestBase { // Check that the selected button is checked. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); - $this->assertFieldChecked('edit-card-1-0'); - $this->assertNoFieldChecked('edit-card-1-1'); - $this->assertNoFieldChecked('edit-card-1-2'); + $this->assertSession()->checkboxChecked('edit-card-1-0'); + $this->assertSession()->checkboxNotChecked('edit-card-1-1'); + $this->assertSession()->checkboxNotChecked('edit-card-1-2'); // Unselect option. $edit = ['card_1' => '_none']; @@ -173,7 +173,7 @@ class OptionsWidgetsTest extends FieldTestBase { $field->setRequired(TRUE); $field->save(); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); - $this->assertFieldChecked('edit-card-1-99'); + $this->assertSession()->checkboxChecked('edit-card-1-99'); } /** @@ -203,9 +203,9 @@ class OptionsWidgetsTest extends FieldTestBase { // Display form: with no field data, nothing is checked. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); - $this->assertNoFieldChecked('edit-card-2-0'); - $this->assertNoFieldChecked('edit-card-2-1'); - $this->assertNoFieldChecked('edit-card-2-2'); + $this->assertSession()->checkboxNotChecked('edit-card-2-0'); + $this->assertSession()->checkboxNotChecked('edit-card-2-1'); + $this->assertSession()->checkboxNotChecked('edit-card-2-2'); $this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.'); // Submit form: select first and third options. @@ -219,9 +219,9 @@ class OptionsWidgetsTest extends FieldTestBase { // Display form: check that the right options are selected. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); - $this->assertFieldChecked('edit-card-2-0'); - $this->assertNoFieldChecked('edit-card-2-1'); - $this->assertFieldChecked('edit-card-2-2'); + $this->assertSession()->checkboxChecked('edit-card-2-0'); + $this->assertSession()->checkboxNotChecked('edit-card-2-1'); + $this->assertSession()->checkboxChecked('edit-card-2-2'); // Submit form: select only first option. $edit = [ @@ -234,9 +234,9 @@ class OptionsWidgetsTest extends FieldTestBase { // Display form: check that the right options are selected. $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); - $this->assertFieldChecked('edit-card-2-0'); - $this->assertNoFieldChecked('edit-card-2-1'); - $this->assertNoFieldChecked('edit-card-2-2'); + $this->assertSession()->checkboxChecked('edit-card-2-0'); + $this->assertSession()->checkboxNotChecked('edit-card-2-1'); + $this->assertSession()->checkboxNotChecked('edit-card-2-2'); // Submit form: select the three options while the field accepts only 2. $edit = [ @@ -263,7 +263,7 @@ class OptionsWidgetsTest extends FieldTestBase { $field->setRequired(TRUE); $field->save(); $this->drupalGet('entity_test/manage/' . $entity->id() . '/edit'); - $this->assertFieldChecked('edit-card-2-99'); + $this->assertSession()->checkboxChecked('edit-card-2-99'); } /** diff --git a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php index 5a56b0c03b21..a85f0e406c2f 100644 --- a/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php +++ b/core/modules/responsive_image/tests/src/Functional/ResponsiveImageAdminUITest.php @@ -132,9 +132,9 @@ class ResponsiveImageAdminUITest extends BrowserTestBase { // Check the mapping for multipliers 1x and 2x for the narrow breakpoint. $this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]', 'sizes'); $this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][sizes]', '(min-resolution: 192dpi) and (min-width: 170px) 386px, (min-width: 170px) 193px, (min-width: 768px) 18vw, (min-width: 480px) 30vw, 48vw'); - $this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-large'); - $this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-medium'); - $this->assertNoFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-thumbnail'); + $this->assertSession()->checkboxChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-large'); + $this->assertSession()->checkboxChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-medium'); + $this->assertSession()->checkboxNotChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-thumbnail'); $this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][2x][image_mapping_type]', '_none'); // Check the mapping for multipliers 1x and 2x for the wide breakpoint. diff --git a/core/modules/search/tests/src/Functional/SearchLanguageTest.php b/core/modules/search/tests/src/Functional/SearchLanguageTest.php index 56e2a2d12858..b1677ef06b46 100644 --- a/core/modules/search/tests/src/Functional/SearchLanguageTest.php +++ b/core/modules/search/tests/src/Functional/SearchLanguageTest.php @@ -139,12 +139,12 @@ class SearchLanguageTest extends BrowserTestBase { // Change the default language and delete English. $path = 'admin/config/regional/language'; $this->drupalGet($path); - $this->assertFieldChecked('edit-site-default-language-en', 'Default language updated.'); + $this->assertSession()->checkboxChecked('edit-site-default-language-en'); $edit = [ 'site_default_language' => 'fr', ]; $this->drupalPostForm($path, $edit, t('Save configuration')); - $this->assertNoFieldChecked('edit-site-default-language-en', 'Default language updated.'); + $this->assertSession()->checkboxNotChecked('edit-site-default-language-en'); $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete')); } diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php index 40aeb1d7f39b..505a7d0628f0 100644 --- a/core/modules/system/tests/src/Functional/Form/FormTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormTest.php @@ -213,15 +213,15 @@ class FormTest extends BrowserTestBase { // Verify that input elements are still empty. $this->assertFieldByName('textfield', ''); - $this->assertNoFieldChecked('edit-checkboxes-foo'); - $this->assertNoFieldChecked('edit-checkboxes-bar'); + $this->assertSession()->checkboxNotChecked('edit-checkboxes-foo'); + $this->assertSession()->checkboxNotChecked('edit-checkboxes-bar'); $this->assertTrue($this->assertSession()->optionExists('edit-select', '')->isSelected()); - $this->assertNoFieldChecked('edit-radios-foo'); - $this->assertNoFieldChecked('edit-radios-bar'); - $this->assertNoFieldChecked('edit-radios-optional-foo'); - $this->assertNoFieldChecked('edit-radios-optional-bar'); - $this->assertNoFieldChecked('edit-radios-optional-default-value-false-foo'); - $this->assertNoFieldChecked('edit-radios-optional-default-value-false-bar'); + $this->assertSession()->checkboxNotChecked('edit-radios-foo'); + $this->assertSession()->checkboxNotChecked('edit-radios-bar'); + $this->assertSession()->checkboxNotChecked('edit-radios-optional-foo'); + $this->assertSession()->checkboxNotChecked('edit-radios-optional-bar'); + $this->assertSession()->checkboxNotChecked('edit-radios-optional-default-value-false-foo'); + $this->assertSession()->checkboxNotChecked('edit-radios-optional-default-value-false-bar'); // Submit again with required fields set and verify that there are no // error messages. @@ -268,10 +268,10 @@ class FormTest extends BrowserTestBase { $this->assertText('The form has become outdated.'); // Ensure that we don't use the posted values. $this->assertFieldByName('textfield', ''); - $this->assertNoFieldChecked('edit-checkboxes-foo'); - $this->assertNoFieldChecked('edit-checkboxes-bar'); + $this->assertSession()->checkboxNotChecked('edit-checkboxes-foo'); + $this->assertSession()->checkboxNotChecked('edit-checkboxes-bar'); $this->assertTrue($this->assertSession()->optionExists('edit-select', '')->isSelected()); - $this->assertNoFieldChecked('edit-radios-foo'); + $this->assertSession()->checkboxNotChecked('edit-radios-foo'); // Check another form that has a textarea input. $this->drupalGet(Url::fromRoute('form_test.required')); diff --git a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php index f0ca2239caa3..83167fa33f23 100644 --- a/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php +++ b/core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php @@ -109,7 +109,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { $this->drupalGet('node/8/edit'); $this->assertText('Test title'); $this->assertText('Test body'); - $this->assertFieldChecked('edit-field-test-1-value'); + $this->assertSession()->checkboxChecked('edit-field-test-1-value'); $this->assertRaw('2015-08-16'); $this->assertRaw('test@example.com'); $this->assertRaw('drupal.org'); @@ -177,10 +177,10 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { // Make sure our custom visibility conditions are correct. $this->drupalGet('admin/structure/block/manage/testblock'); - $this->assertNoFieldChecked('edit-visibility-language-langcodes-es'); - $this->assertFieldChecked('edit-visibility-language-langcodes-en'); - $this->assertNoFieldChecked('edit-visibility-node-type-bundles-book'); - $this->assertFieldChecked('edit-visibility-node-type-bundles-test-content-type'); + $this->assertSession()->checkboxNotChecked('edit-visibility-language-langcodes-es'); + $this->assertSession()->checkboxChecked('edit-visibility-language-langcodes-en'); + $this->assertSession()->checkboxNotChecked('edit-visibility-node-type-bundles-book'); + $this->assertSession()->checkboxChecked('edit-visibility-node-type-bundles-test-content-type'); // Make sure our block is still translated. $this->drupalGet('admin/structure/block/manage/testblock/translate/es/edit'); @@ -219,7 +219,7 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { $this->assertRaw('Menu test'); // Make sure our custom menu link exists. $this->drupalGet('admin/structure/menu/item/1/edit'); - $this->assertFieldChecked('edit-enabled-value'); + $this->assertSession()->checkboxChecked('edit-enabled-value'); // Make sure our comment type exists. $this->drupalGet('admin/structure/comment'); @@ -293,11 +293,11 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest { // Make sure our language detection settings are still correct. $this->drupalGet('admin/config/regional/language/detection'); - $this->assertFieldChecked('edit-language-interface-enabled-language-user-admin'); - $this->assertFieldChecked('edit-language-interface-enabled-language-url'); - $this->assertFieldChecked('edit-language-interface-enabled-language-session'); - $this->assertFieldChecked('edit-language-interface-enabled-language-user'); - $this->assertFieldChecked('edit-language-interface-enabled-language-browser'); + $this->assertSession()->checkboxChecked('edit-language-interface-enabled-language-user-admin'); + $this->assertSession()->checkboxChecked('edit-language-interface-enabled-language-url'); + $this->assertSession()->checkboxChecked('edit-language-interface-enabled-language-session'); + $this->assertSession()->checkboxChecked('edit-language-interface-enabled-language-user'); + $this->assertSession()->checkboxChecked('edit-language-interface-enabled-language-browser'); // Make sure strings are still translated. $this->drupalGet('admin/structure/views/view/content/translate/es/edit'); diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php index 602407a3b0e1..ac559eca7502 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyLanguageTest.php @@ -94,7 +94,7 @@ class VocabularyLanguageTest extends TaxonomyTestBase { // Check that the correct options are selected in the interface. $this->assertTrue($this->assertSession()->optionExists('edit-default-language-langcode', 'bb')->isSelected()); - $this->assertFieldChecked('edit-default-language-language-alterable', 'Show language selection option is checked.'); + $this->assertSession()->checkboxChecked('edit-default-language-language-alterable'); // Edit the vocabulary and check that the new settings are updated. $edit = [ @@ -110,7 +110,7 @@ class VocabularyLanguageTest extends TaxonomyTestBase { $this->drupalGet('admin/structure/taxonomy/manage/' . $vid); $this->assertTrue($this->assertSession()->optionExists('edit-default-language-langcode', 'aa')->isSelected()); - $this->assertNoFieldChecked('edit-default-language-language-alterable', 'Show language selection option is not checked.'); + $this->assertSession()->checkboxNotChecked('edit-default-language-language-alterable'); // Check that language settings are changed after editing vocabulary. $edit = [ diff --git a/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php b/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php index d9990edd41ce..062e1f827743 100644 --- a/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php @@ -52,7 +52,7 @@ class VocabularyTranslationTest extends TaxonomyTestBase { // Check if content translation is enabled on the edit page. $this->drupalGet('admin/structure/taxonomy/manage/' . $vid); - $this->assertFieldChecked('edit-default-language-content-translation', 'The content translation was correctly selected.'); + $this->assertSession()->checkboxChecked('edit-default-language-content-translation'); } } diff --git a/core/modules/user/tests/src/Functional/UserAccountLinksTest.php b/core/modules/user/tests/src/Functional/UserAccountLinksTest.php index d9b44bfc747a..595e6cf270c9 100644 --- a/core/modules/user/tests/src/Functional/UserAccountLinksTest.php +++ b/core/modules/user/tests/src/Functional/UserAccountLinksTest.php @@ -97,7 +97,7 @@ class UserAccountLinksTest extends BrowserTestBase { // the consistent label text. $this->drupalGet('admin/structure/menu/manage/account'); $label = $this->xpath('//label[contains(.,:text)]/@for', [':text' => 'Enable My account menu link']); - $this->assertFieldChecked($label[0]->getText(), "The 'My account' link is enabled by default."); + $this->assertSession()->checkboxChecked($label[0]->getText()); // Disable the 'My account' link. $edit['links[menu_plugin_id:user.page][enabled]'] = FALSE; diff --git a/core/modules/user/tests/src/Functional/UserEditTest.php b/core/modules/user/tests/src/Functional/UserEditTest.php index 6a71927a96cc..60c770123ac1 100644 --- a/core/modules/user/tests/src/Functional/UserEditTest.php +++ b/core/modules/user/tests/src/Functional/UserEditTest.php @@ -106,20 +106,20 @@ class UserEditTest extends BrowserTestBase { $this->drupalLogin($admin_user); $this->drupalGet('user/' . $user1->id() . '/edit'); - $this->assertNoFieldChecked('edit-status-0'); - $this->assertFieldChecked('edit-status-1'); + $this->assertSession()->checkboxNotChecked('edit-status-0'); + $this->assertSession()->checkboxChecked('edit-status-1'); $edit = ['status' => 0]; $this->drupalPostForm('user/' . $user1->id() . '/edit', $edit, t('Save')); $this->assertText(t('The changes have been saved.')); - $this->assertFieldChecked('edit-status-0'); - $this->assertNoFieldChecked('edit-status-1'); + $this->assertSession()->checkboxChecked('edit-status-0'); + $this->assertSession()->checkboxNotChecked('edit-status-1'); $edit = ['status' => 1]; $this->drupalPostForm('user/' . $user1->id() . '/edit', $edit, t('Save')); $this->assertText(t('The changes have been saved.')); - $this->assertNoFieldChecked('edit-status-0'); - $this->assertFieldChecked('edit-status-1'); + $this->assertSession()->checkboxNotChecked('edit-status-0'); + $this->assertSession()->checkboxChecked('edit-status-1'); } /** diff --git a/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php b/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php index 0f3e358ee8c5..285169d0d88f 100644 --- a/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php +++ b/core/modules/user/tests/src/Functional/UserRolesAssignmentTest.php @@ -36,13 +36,13 @@ class UserRolesAssignmentTest extends BrowserTestBase { // Assign the role to the user. $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => $rid], t('Save')); $this->assertText(t('The changes have been saved.')); - $this->assertFieldChecked('edit-roles-' . $rid, 'Role is assigned.'); + $this->assertSession()->checkboxChecked('edit-roles-' . $rid); $this->userLoadAndCheckRoleAssigned($account, $rid); // Remove the role from the user. $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => FALSE], t('Save')); $this->assertText(t('The changes have been saved.')); - $this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.'); + $this->assertSession()->checkboxNotChecked('edit-roles-' . $rid); $this->userLoadAndCheckRoleAssigned($account, $rid, FALSE); } @@ -66,13 +66,13 @@ class UserRolesAssignmentTest extends BrowserTestBase { $account = user_load_by_name($edit['name']); $this->drupalGet('user/' . $account->id() . '/edit'); - $this->assertFieldChecked('edit-roles-' . $rid, 'Role is assigned.'); + $this->assertSession()->checkboxChecked('edit-roles-' . $rid); $this->userLoadAndCheckRoleAssigned($account, $rid); // Remove the role again. $this->drupalPostForm('user/' . $account->id() . '/edit', ["roles[$rid]" => FALSE], t('Save')); $this->assertText(t('The changes have been saved.')); - $this->assertNoFieldChecked('edit-roles-' . $rid, 'Role is removed from user.'); + $this->assertSession()->checkboxNotChecked('edit-roles-' . $rid); $this->userLoadAndCheckRoleAssigned($account, $rid, FALSE); } diff --git a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php index d9b2faf834b4..5911b1548eb7 100644 --- a/core/modules/views/tests/src/Functional/Handler/HandlerTest.php +++ b/core/modules/views/tests/src/Functional/Handler/HandlerTest.php @@ -292,7 +292,7 @@ class HandlerTest extends ViewTestBase { // Check content type filter options. $this->drupalGet('admin/structure/views/nojs/handler/test_get_entity_type/default/filter/type'); $this->assertTrue($this->assertSession()->optionExists('edit-options-relationship', 'node')->isSelected()); - $this->assertFieldChecked('edit-options-value-page'); + $this->assertSession()->checkboxChecked('edit-options-value-page'); } /** diff --git a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php index bcbf4b709bb3..7bd137dd530a 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\views_ui\Functional; -use Drupal\Component\Render\FormattableMarkup; use Drupal\views\Views; /** @@ -38,9 +37,8 @@ class DisplayAttachmentTest extends UITestBase { // Display labels should be escaped. $this->assertEscaped('Page'); - foreach (['default', 'page-1'] as $display_id) { - $this->assertNoFieldChecked("edit-displays-$display_id", new FormattableMarkup('Make sure the @display_id can be marked as attached', ['@display_id' => $display_id])); - } + $this->assertSession()->checkboxNotChecked("edit-displays-default"); + $this->assertSession()->checkboxNotChecked("edit-displays-page-1"); // Save the attachments and test the value on the view. $this->drupalPostForm($attachment_display_url, ['displays[page_1]' => 1], t('Apply')); diff --git a/core/modules/views_ui/tests/src/Functional/DisplayTest.php b/core/modules/views_ui/tests/src/Functional/DisplayTest.php index 85d2efd91bf8..d22e76a8556b 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php @@ -159,7 +159,7 @@ class DisplayTest extends UITestBase { $this->assertEqual($result[0]->getHtml(), t('None'), 'Make sure that the link option summary shows "None" by default.'); $this->drupalGet($link_display_path); - $this->assertFieldChecked('edit-link-display-0'); + $this->assertSession()->checkboxChecked('edit-link-display-0'); // Test the default radio option on the link display form. $this->drupalPostForm($link_display_path, ['link_display' => 'page_1'], t('Apply')); diff --git a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php index 28eef978645c..dbda21b3bded 100644 --- a/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php @@ -324,9 +324,9 @@ class ExposedFormUITest extends UITestBase { $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status'); // Assert the same settings defined before still are there. - $this->assertFieldChecked('edit-options-group-info-group-items-1-value-all'); - $this->assertFieldChecked('edit-options-group-info-group-items-2-value-1'); - $this->assertFieldChecked('edit-options-group-info-group-items-3-value-0'); + $this->assertSession()->checkboxChecked('edit-options-group-info-group-items-1-value-all'); + $this->assertSession()->checkboxChecked('edit-options-group-info-group-items-2-value-1'); + $this->assertSession()->checkboxChecked('edit-options-group-info-group-items-3-value-0'); } } diff --git a/core/modules/views_ui/tests/src/Functional/SettingsTest.php b/core/modules/views_ui/tests/src/Functional/SettingsTest.php index 1e43f55813b3..be6e218f03b6 100644 --- a/core/modules/views_ui/tests/src/Functional/SettingsTest.php +++ b/core/modules/views_ui/tests/src/Functional/SettingsTest.php @@ -138,8 +138,8 @@ class SettingsTest extends UITestBase { ]; $this->drupalPostForm('admin/structure/views/settings/advanced', $edit, t('Save configuration')); - $this->assertFieldChecked('edit-skip-cache', 'The skip_cache option is checked.'); - $this->assertFieldChecked('edit-sql-signature', 'The sql_signature option is checked.'); + $this->assertSession()->checkboxChecked('edit-skip-cache'); + $this->assertSession()->checkboxChecked('edit-sql-signature'); // Test the "Clear Views' cache" button. $this->drupalPostForm('admin/structure/views/settings/advanced', [], t("Clear Views' cache")); diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index f91bdfaecc96..c112af007561 100644 --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -590,6 +590,19 @@ class BrowserTestBaseTest extends BrowserTestBase { } } + /** + * Tests legacy assertFieldChecked() and assertNoFieldChecked(). + * + * @group legacy + * @expectedDeprecation AssertLegacyTrait::assertFieldChecked() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->checkboxChecked() instead. See https://www.drupal.org/node/3129738 + * @expectedDeprecation AssertLegacyTrait::assertNoFieldChecked() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->checkboxNotChecked() instead. See https://www.drupal.org/node/3129738 + */ + public function testLegacyFieldAssertsForCheckbox() { + $this->drupalGet('test-field-xpath'); + $this->assertFieldChecked('edit-checkbox-enabled'); + $this->assertNoFieldChecked('edit-checkbox-disabled'); + } + /** * Tests legacy field asserts for checkbox field type. */ @@ -657,12 +670,12 @@ class BrowserTestBaseTest extends BrowserTestBase { } // Part 3 - Test the specific 'checked' assertions. - $this->assertFieldChecked('edit-checkbox-enabled'); - $this->assertNoFieldChecked('edit-checkbox-disabled'); + $this->assertSession()->checkboxChecked('edit-checkbox-enabled'); + $this->assertSession()->checkboxNotChecked('edit-checkbox-disabled'); // Test that the assertion fails correctly with non-existent field id. try { - $this->assertNoFieldChecked('incorrect_checkbox_id'); + $this->assertSession()->checkboxNotChecked('incorrect_checkbox_id'); $this->fail('The "incorrect_checkbox_id" field was found'); } catch (ExpectationException $e) { @@ -671,7 +684,7 @@ class BrowserTestBaseTest extends BrowserTestBase { // Test that the assertion fails correctly for a checkbox that is checked. try { - $this->assertNoFieldChecked('edit-checkbox-enabled'); + $this->assertSession()->checkboxNotChecked('edit-checkbox-enabled'); $this->fail('The "edit-checkbox-enabled" field was not found in a checked state.'); } catch (ExpectationException $e) { @@ -681,7 +694,7 @@ class BrowserTestBaseTest extends BrowserTestBase { // Test that the assertion fails correctly for a checkbox that is not // checked. try { - $this->assertFieldChecked('edit-checkbox-disabled'); + $this->assertSession()->checkboxChecked('edit-checkbox-disabled'); $this->fail('The "edit-checkbox-disabled" field was found and checked.'); } catch (ExpectationException $e) { diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 88728ea1f5d5..d1ad7a1d1271 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -185,8 +185,6 @@ trait DeprecationListenerTrait { 'AssertLegacyTrait::assertNoLinkByHref() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->linkByHrefNotExists() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNoFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() or $this->assertSession()->fieldValueNotEquals() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertUrl() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->addressEquals() instead. See https://www.drupal.org/node/3129738', - 'AssertLegacyTrait::assertFieldChecked() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->checkboxChecked() instead. See https://www.drupal.org/node/3129738', - 'AssertLegacyTrait::assertNoFieldChecked() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->checkboxNotChecked() instead. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and check the values directly in the test. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertNoFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and assert that the result is empty. See https://www.drupal.org/node/3129738', 'AssertLegacyTrait::assertFieldsByValue() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use iteration over the fields yourself instead and directly check the values in the test. See https://www.drupal.org/node/3129738',