Issue #3139428 by jungle, ridhimaabrol24, Hardik_Patel_12, mondrake, mrinalini9, Bunty Badgujar: Replace usages of deprecated AssertLegacyTrait::assert(No)FieldChecked()

merge-requests/2/head
Alex Pott 2020-07-15 23:46:47 +01:00
parent 0f823ffd28
commit 09c6b3d80d
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
35 changed files with 140 additions and 131 deletions

View File

@ -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.');

View File

@ -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();

View File

@ -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

View File

@ -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 = [

View File

@ -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');
}

View File

@ -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');

View File

@ -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];

View File

@ -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');
}
}

View File

@ -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');
}

View File

@ -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

View File

@ -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.

View File

@ -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');
}
/**

View File

@ -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);

View File

@ -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');
}
}

View File

@ -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];

View File

@ -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 = [];

View File

@ -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');

View File

@ -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

View File

@ -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 &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
$this->assertRaw('Some HTML encoded markup with &lt; &amp; &gt;');
@ -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 &amp; unescaped <strong>markup</strong>', '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');
}
/**

View File

@ -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.

View File

@ -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'));
}

View File

@ -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'));

View File

@ -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');

View File

@ -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 = [

View File

@ -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');
}
}

View File

@ -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;

View File

@ -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');
}
/**

View File

@ -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);
}

View File

@ -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');
}
/**

View File

@ -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('<em>Page</em>');
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'));

View File

@ -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'));

View File

@ -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');
}
}

View File

@ -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"));

View File

@ -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) {

View File

@ -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',