Commit 30ca835c authored by catch's avatar catch
Browse files

Issue #3139408 by mondrake, jungle, dww: Replace usages of...

Issue #3139408 by mondrake, jungle, dww: Replace usages of AssertLegacyTrait::assert(No)Field, that is deprecated
parent f5f925c0
......@@ -48,9 +48,9 @@ public function openImportForm() {
$this->drupalGet('admin/config/services/aggregator/add/opml');
$this->assertText('A single OPML document may contain many feeds.', 'Found OPML help text.');
// Ensure that the file upload, remote URL, and refresh fields exist.
$this->assertField('files[upload]');
$this->assertField('remote');
$this->assertField('refresh');
$this->assertSession()->fieldExists('files[upload]');
$this->assertSession()->fieldExists('remote');
$this->assertSession()->fieldExists('refresh');
}
/**
......
......@@ -56,8 +56,8 @@ public function testLanguageBlockVisibility() {
$this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
// Ensure that the language visibility field is visible without a type
// setting.
$this->assertField('visibility[language][langcodes][en]');
$this->assertNoField('visibility[language][context_mapping][language]');
$this->assertSession()->fieldExists('visibility[language][langcodes][en]');
$this->assertSession()->fieldNotExists('visibility[language][context_mapping][language]');
// Enable a standard block and set the visibility setting for one language.
$edit = [
......@@ -139,8 +139,8 @@ public function testMultipleLanguageTypes() {
// Check if the visibility setting is available with a type setting.
$default_theme = $this->config('system.theme')->get('default');
$this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme);
$this->assertField('visibility[language][langcodes][en]');
$this->assertField('visibility[language][context_mapping][language]');
$this->assertSession()->fieldExists('visibility[language][langcodes][en]');
$this->assertSession()->fieldExists('visibility[language][context_mapping][language]');
// Enable a standard block and set visibility to French only.
$block_id = strtolower($this->randomMachineName(8));
......
......@@ -121,11 +121,11 @@ public function testBlockAdminUiPage() {
$element = $this->xpath('//*[@id="blocks"]/tbody/tr[' . $values['tr'] . ']/td[1]/text()');
$this->assertEquals($element[0]->getText(), $label, 'The "' . $label . '" block title is set inside the ' . $values['settings']['region'] . ' region.');
// Look for a test block region select form element.
$this->assertField('blocks[' . $values['settings']['id'] . '][region]');
$this->assertSession()->fieldExists('blocks[' . $values['settings']['id'] . '][region]');
// Move the test block to the header region.
$edit['blocks[' . $values['settings']['id'] . '][region]'] = 'header';
// Look for a test block weight select form element.
$this->assertField('blocks[' . $values['settings']['id'] . '][weight]');
$this->assertSession()->fieldExists('blocks[' . $values['settings']['id'] . '][weight]');
// Change the test block's weight.
$edit['blocks[' . $values['settings']['id'] . '][weight]'] = $values['test_weight'];
}
......
......@@ -73,7 +73,7 @@ public function testBookCommentPrint() {
$this->assertText($comment_body, 'Comment body found');
$this->assertText(t('Add new comment'), 'Comment form found');
// Ensure that the comment form subject field exists.
$this->assertField('subject[0][value]');
$this->assertSession()->fieldExists('subject[0][value]');
$this->drupalGet('book/export/html/' . $book_node->id());
......@@ -83,7 +83,7 @@ public function testBookCommentPrint() {
$this->assertNoText(t('Add new comment'), 'Comment form not found');
// Verify that the comment form subject field is not found.
$this->assertNoField('subject[0][value]');
$this->assertSession()->fieldNotExists('subject[0][value]');
}
}
......@@ -179,14 +179,14 @@ public function testCommentInterface() {
$this->assertNotNull($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertSession()->statusCodeEquals(403);
$this->assertNoField('edit-comment');
$this->assertSession()->fieldNotExists('edit-comment');
// Attempt to post to node with read-only comments.
$this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::CLOSED]]]);
$this->assertNotNull($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertSession()->statusCodeEquals(403);
$this->assertNoField('edit-comment');
$this->assertSession()->fieldNotExists('edit-comment');
// Attempt to post to node with comments enabled (check field names etc).
$this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::OPEN]]]);
......@@ -194,7 +194,7 @@ public function testCommentInterface() {
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertNoText('This discussion is closed', 'Posting to node with comments enabled');
// Ensure that the comment body field exists.
$this->assertField('edit-comment-body-0-value');
$this->assertSession()->fieldExists('edit-comment-body-0-value');
// Delete comment and make sure that reply is also removed.
$this->drupalLogout();
......
......@@ -276,12 +276,12 @@ public function testCommentFunctionality() {
// Test widget hidden option is not visible when there's no comments.
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoField('edit-default-value-input-comment-und-0-status-0');
$this->assertSession()->fieldNotExists('edit-default-value-input-comment-und-0-status-0');
// Test that field to change cardinality is not available.
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment/storage');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoField('cardinality_number');
$this->assertNoField('cardinality');
$this->assertSession()->fieldNotExists('cardinality_number');
$this->assertSession()->fieldNotExists('cardinality');
$this->drupalLogin($this->adminUser);
......@@ -451,7 +451,7 @@ public function testCommentFunctionality() {
$this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit');
$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');
$this->assertSession()->fieldNotExists('edit-field-foobar-0-status-0');
// @todo Check proper url and form https://www.drupal.org/node/2458323
$this->drupalGet('comment/reply/entity_test/comment/' . $new_entity->id());
......
......@@ -85,7 +85,7 @@ public function testCommentTypeCreation() {
// Edit the comment-type and ensure that we cannot change the entity-type.
$this->drupalGet('admin/structure/comment/manage/foo');
$this->assertNoField('target_entity_type_id');
$this->assertSession()->fieldNotExists('target_entity_type_id');
$this->assertText(t('Target entity type'));
// Save the form and ensure the entity-type value is preserved even though
// the field isn't present.
......
......@@ -56,9 +56,9 @@ public function testApprovalAdminInterface() {
$this->assertText(t('No comments available.'));
// Assert the expose filters on the admin page.
$this->assertField('subject');
$this->assertField('author_name');
$this->assertField('langcode');
$this->assertSession()->fieldExists('subject');
$this->assertSession()->fieldExists('author_name');
$this->assertSession()->fieldExists('langcode');
$this->drupalLogout();
......@@ -110,9 +110,9 @@ public function testApprovalAdminInterface() {
$this->assertText(t('Unapproved comments (@count)', ['@count' => 2]), 'Two unapproved comments waiting for approval.');
// Assert the expose filters on the admin page.
$this->assertField('subject');
$this->assertField('author_name');
$this->assertField('langcode');
$this->assertSession()->fieldExists('subject');
$this->assertSession()->fieldExists('author_name');
$this->assertSession()->fieldExists('langcode');
$edit = [
"action" => 'comment_publish_action',
......
......@@ -53,11 +53,11 @@ public function testDateFormatUI() {
// Date pattern is visible on unlocked date formats.
$this->drupalGet('admin/config/regional/date-time/formats/manage/medium/translate/de/add');
$this->assertField('translation[config_names][core.date_format.medium][pattern]');
$this->assertSession()->fieldExists('translation[config_names][core.date_format.medium][pattern]');
// Date pattern is not visible on locked date formats.
$this->drupalGet('admin/config/regional/date-time/formats/manage/html_datetime/translate/es/add');
$this->assertNoField('translation[config_names][core.date_format.html_datetime][pattern]');
$this->assertSession()->fieldNotExists('translation[config_names][core.date_format.html_datetime][pattern]');
}
}
......@@ -52,7 +52,7 @@ public function testContactLanguage() {
// Ensure that contact form by default does not show the language select.
$this->drupalGet('contact');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoField('edit-langcode-0-value');
$this->assertSession()->fieldNotExists('edit-langcode-0-value');
// Enable language select from content language settings page.
$settings_path = 'admin/config/regional/content-language';
......@@ -63,7 +63,7 @@ public function testContactLanguage() {
// Ensure that contact form now shows the language select.
$this->drupalGet('contact');
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-langcode-0-value');
$this->assertSession()->fieldExists('edit-langcode-0-value');
}
}
......@@ -79,7 +79,7 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-new-state');
$this->assertSession()->fieldExists('edit-new-state');
// The latest version page should not show, because there is no pending
// revision.
......@@ -96,7 +96,7 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-new-state');
$this->assertSession()->fieldExists('edit-new-state');
// Preview the draft.
$this->drupalPostForm($edit_path, [
......@@ -111,7 +111,7 @@ public function testModerationForm() {
]);
$this->assertSession()->statusCodeEquals(200);
$this->assertUrl($preview_url);
$this->assertNoField('edit-new-state');
$this->assertSession()->fieldNotExists('edit-new-state');
// The latest version page should not show, because there is still no
// pending revision.
......@@ -141,7 +141,7 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertNoField('edit-new-state');
$this->assertSession()->fieldNotExists('edit-new-state');
// The latest version page should not show, because there is still no
// pending revision.
......@@ -158,13 +158,13 @@ public function testModerationForm() {
// live revision.
$this->drupalGet($canonical_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertNoField('edit-new-state');
$this->assertSession()->fieldNotExists('edit-new-state');
// The latest version page should show the moderation form and have "Draft"
// status, because the pending revision is in "Draft".
$this->drupalGet($latest_version_path);
$this->assertSession()->statusCodeEquals(200);
$this->assertField('edit-new-state');
$this->assertSession()->fieldExists('edit-new-state');
$this->assertText('Draft', 'Correct status found on the latest-version page.');
// Submit the moderation form to change status to published.
......
......@@ -157,7 +157,7 @@ public function testSettingsUI() {
// Verify language widget appears on comment type form.
$this->drupalGet('admin/structure/comment/manage/comment_article');
$this->assertField('language_configuration[content_translation]');
$this->assertSession()->fieldExists('language_configuration[content_translation]');
$this->assertSession()->checkboxChecked('edit-language-configuration-content-translation');
// Verify that translation may be enabled for the article content type.
......@@ -166,7 +166,7 @@ public function testSettingsUI() {
];
// 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->assertSession()->fieldExists('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');
......@@ -227,7 +227,7 @@ public function testSettingsUI() {
public function testAccountLanguageSettingsUI() {
// Make sure the checkbox is available and not checked by default.
$this->drupalGet('admin/config/people/accounts');
$this->assertField('language[content_translation]');
$this->assertSession()->fieldExists('language[content_translation]');
$this->assertSession()->checkboxNotChecked('edit-language-content-translation');
$edit = [
......@@ -305,7 +305,7 @@ public function testFieldTranslatableSettingsUI() {
*/
public function testNonTranslatableTranslationSettingsUI() {
$this->drupalGet('admin/config/regional/content-language');
$this->assertNoField('settings[entity_test][entity_test][translatable]');
$this->assertSession()->fieldNotExists('settings[entity_test][entity_test][translatable]');
}
}
......@@ -124,7 +124,7 @@ public function testFieldFormSingle() {
$this->assertText($token_description, 'Token replacement for description is displayed');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[1][value]");
$this->assertSession()->fieldNotExists("{$field_name}[1][value]");
// Check that hook_field_widget_form_alter() does not believe this is the
// default value form.
......@@ -157,7 +157,7 @@ public function testFieldFormSingle() {
$this->drupalGet('entity_test/manage/' . $id . '/edit');
$this->assertFieldByName("{$field_name}[0][value]", $value, 'Widget is displayed with the correct default value');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[1][value]");
$this->assertSession()->fieldNotExists("{$field_name}[1][value]");
// Update the entity.
$value = mt_rand(1, 127);
......@@ -268,7 +268,7 @@ public function testFieldFormUnlimited() {
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[1][value]");
$this->assertSession()->fieldNotExists("{$field_name}[1][value]");
// Check if aria-describedby attribute is placed on multiple value widgets.
$elements = $this->xpath('//table[@id="field-unlimited-values" and @aria-describedby="edit-field-unlimited--description"]');
......@@ -279,7 +279,7 @@ public function testFieldFormUnlimited() {
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
$this->assertFieldByName("{$field_name}[1][value]", '', 'New widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[2][value]");
$this->assertSession()->fieldNotExists("{$field_name}[2][value]");
// TODO : check that non-field inputs are preserved ('title'), etc.
// Yet another time so that we can play with more values -> 3 widgets.
......@@ -320,7 +320,7 @@ public function testFieldFormUnlimited() {
$this->assertFieldByName("{$field_name}[$delta][value]", '', "New widget is displayed");
$this->assertFieldByName("{$field_name}[$delta][_weight]", $delta, "New widget has the right weight");
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[" . ($delta + 1) . '][value]');
$this->assertSession()->fieldNotExists("{$field_name}[" . ($delta + 1) . '][value]');
// Submit the form and create the entity.
$this->drupalPostForm(NULL, $edit, t('Save'));
......@@ -418,7 +418,7 @@ public function testFieldFormMultivalueWithRequiredRadio() {
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget 1 is displayed');
$this->assertFieldByName("{$field_name}[1][value]", '', 'New widget is displayed');
// Verify that no extraneous widget is displayed.
$this->assertNoField("{$field_name}[2][value]");
$this->assertSession()->fieldNotExists("{$field_name}[2][value]");
}
/**
......@@ -595,7 +595,7 @@ public function testHiddenField() {
// Create an entity and test that the default value is assigned correctly to
// the field that uses the hidden widget.
$this->assertNoField("{$field_name}[0][value]");
$this->assertSession()->fieldNotExists("{$field_name}[0][value]");
$this->drupalPostForm(NULL, [], t('Save'));
preg_match('|' . $entity_type . '/manage/(\d+)|', $this->getUrl(), $match);
$id = $match[1];
......
......@@ -353,7 +353,7 @@ private function doAdminTests($user) {
// Test term edit form alterations.
$this->drupalGet('taxonomy/term/' . $this->forumContainer['tid'] . '/edit');
// Test parent field been hidden by forum module.
$this->assertNoField('parent[]');
$this->assertSession()->fieldNotExists('parent[]');
// Create a default vocabulary named "Tags".
$description = 'Use tags to group articles on similar topics into categories.';
......@@ -372,7 +372,7 @@ private function doAdminTests($user) {
$this->assertSession()->linkExists(t('Delete'));
// Test tags vocabulary term form is not affected.
$this->drupalGet('admin/structure/taxonomy/manage/tags/add');
$this->assertField('parent[]', 'Parent field found.');
$this->assertSession()->fieldExists('parent[]');
// Test relations widget exists.
$relations_widget = $this->xpath("//details[@id='edit-relations']");
$this->assertTrue(isset($relations_widget[0]), 'Relations widget element found.');
......
......@@ -49,7 +49,7 @@ public function testEmptyLangcode() {
// Assert that we can not enable language select from
// content language settings page.
$this->drupalGet('admin/config/regional/content-language');
$this->assertNoField('entity_types[no_language_entity_test]');
$this->assertSession()->fieldNotExists('entity_types[no_language_entity_test]');
}
}
......@@ -61,7 +61,7 @@ public function testUIBrowserLanguageMappings() {
// Check we went back to the browser negotiation mapping overview.
$this->assertUrl(Url::fromRoute('language.negotiation_browser', [], ['absolute' => TRUE])->toString());
// Check that Chinese browser language code no longer exists.
$this->assertNoField('edit-mappings-zh-cn-browser-langcode');
$this->assertSession()->fieldNotExists('edit-mappings-zh-cn-browser-langcode');
// Add a new custom mapping.
$edit = [
......
......@@ -142,7 +142,7 @@ public function testMenuLanguage() {
// Check that the language selector is not available on menu link add page.
$this->drupalGet("admin/structure/menu/manage/$menu_name/add");
$this->assertNoField('edit-langcode-0-value');
$this->assertSession()->fieldNotExists('edit-langcode-0-value');
}
}
......@@ -55,7 +55,7 @@ public function testNodeTypeInitialLanguageDefaults() {
// Verify that language is not selectable on node add page by default.
$this->drupalGet('node/add/article');
$this->assertNoField('langcode');
$this->assertSession()->fieldNotExists('langcode');
// Adds a new language and set it as default.
$edit = [
......@@ -76,7 +76,7 @@ public function testNodeTypeInitialLanguageDefaults() {
$this->drupalGet('node/add/article');
// Ensure that the language is selectable on node add page when language
// not hidden.
$this->assertField('langcode[0][value]');
$this->assertSession()->fieldExists('langcode[0][value]');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'hu')->isSelected());
// Tests if the language field can be rearranged on the manage form display
......
......@@ -54,13 +54,13 @@ public function testAuthProvidersOptions() {
$this->drupalGet("admin/structure/views/nojs/display/$view_id/$view_display/auth");
// The "basic_auth" will always be available since module,
// providing it, has the same name.
$this->assertField('edit-auth-basic-auth');
$this->assertSession()->fieldExists('edit-auth-basic-auth');
// The "cookie" authentication provider defined by "user" module.
$this->assertField('edit-auth-cookie');
$this->assertSession()->fieldExists('edit-auth-cookie');
// Wrong behavior in "getAuthOptions()" method makes this option available
// instead of "cookie".
// @see \Drupal\rest\Plugin\views\display\RestExport::getAuthOptions()
$this->assertNoField('edit-auth-user');
$this->assertSession()->fieldNotExists('edit-auth-user');
$this->drupalPostForm(NULL, ['auth[basic_auth]' => 1, 'auth[cookie]' => 1], 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
......
......@@ -37,8 +37,8 @@ public function testConfigForm() {
$article->save();
$this->drupalGet('condition_test');
$this->assertField('bundles[article]');
$this->assertField('bundles[page]');
$this->assertSession()->fieldExists('bundles[article]');
$this->assertSession()->fieldExists('bundles[page]');
$this->drupalPostForm(NULL, ['bundles[page]' => 'page', 'bundles[article]' => 'article'], t('Submit'));
// @see \Drupal\condition_test\FormController::submitForm()
$this->assertText('Bundle: page');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment