Commit a14e48a1 authored by catch's avatar catch
Browse files

Issue #3139406 by mondrake, mohrerao, longwave, rahulrasgon, Suresh Prabhu...

Issue #3139406 by mondrake, mohrerao, longwave, rahulrasgon, Suresh Prabhu Parkala, jungle, ravi.shankar, Hardik_Patel_12, Bunty Badgujar, paulocs: Replace usages of AssertLegacyTrait::assert(No)FieldByName, that is deprecated
parent 77ce58a2
......@@ -2,8 +2,6 @@
namespace Drupal\Tests\aggregator\Functional;
use Drupal\Component\Render\FormattableMarkup;
/**
* Tests aggregator admin pages.
*
......@@ -41,8 +39,9 @@ public function testSettingsPage() {
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
// Check that settings have the correct default value.
foreach ($edit as $name => $value) {
$this->assertFieldByName($name, $value, new FormattableMarkup('"@name" has correct default value.', ['@name' => $name]));
$this->assertSession()->fieldValueEquals($name, $value);
}
// Check for our test processor settings form.
......@@ -53,7 +52,7 @@ public function testSettingsPage() {
];
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->assertFieldByName('dummy_length', 100, '"dummy_length" has correct default value.');
$this->assertSession()->fieldValueEquals('dummy_length', 100);
// Make sure settings form is still accessible even after uninstalling a module
// that provides the selected plugins.
......
......@@ -277,22 +277,24 @@ public function testContextAwareBlocks() {
* Tests that the BlockForm populates machine name correctly.
*/
public function testMachineNameSuggestion() {
// Check the form uses the raw machine name suggestion when no instance
// already exists.
$url = 'admin/structure/block/add/test_block_instantiation/classy';
$this->drupalGet($url);
$this->assertFieldByName('id', 'displaymessage', 'Block form uses raw machine name suggestion when no instance already exists.');
$this->assertSession()->fieldValueEquals('id', 'displaymessage');
$edit = ['region' => 'content'];
$this->drupalPostForm($url, $edit, 'Save block');
$this->assertText('The block configuration has been saved.');
// Now, check to make sure the form starts by autoincrementing correctly.
$this->drupalGet($url);
$this->assertFieldByName('id', 'displaymessage_2', 'Block form appends _2 to plugin-suggested machine name when an instance already exists.');
$this->assertSession()->fieldValueEquals('id', 'displaymessage_2');
$this->drupalPostForm($url, $edit, 'Save block');
$this->assertText('The block configuration has been saved.');
// And verify that it continues working beyond just the first two.
$this->drupalGet($url);
$this->assertFieldByName('id', 'displaymessage_3', 'Block form appends _3 to plugin-suggested machine name when two instances already exist.');
$this->assertSession()->fieldValueEquals('id', 'displaymessage_3');
}
/**
......
......@@ -44,8 +44,8 @@ public function testListing() {
$this->assertSession()->titleEquals('Custom block library | Drupal');
// Test for the exposed filters.
$this->assertFieldByName('info');
$this->assertFieldByName('type');
$this->assertSession()->fieldExists('info');
$this->assertSession()->fieldExists('type');
// Test for the table.
$element = $this->xpath('//div[@class="layout-content"]//table');
......
......@@ -44,8 +44,8 @@ public function testPageEdit() {
// Load the edit page.
$this->drupalGet('block/' . $block->id());
$this->assertFieldByName($title_key, $edit[$title_key], 'Title field displayed.');
$this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.');
$this->assertSession()->fieldValueEquals($title_key, $edit[$title_key]);
$this->assertSession()->fieldValueEquals($body_key, $edit[$body_key]);
// Edit the content of the block.
$edit = [];
......
......@@ -136,7 +136,7 @@ public function testExistingFormat() {
// Ensure the toolbar buttons configuration value is initialized to the
// expected default value.
$expected_buttons_value = json_encode($expected_default_settings['toolbar']['rows']);
$this->assertFieldByName('editor[settings][toolbar][button_groups]', $expected_buttons_value);
$this->assertSession()->fieldValueEquals('editor[settings][toolbar][button_groups]', $expected_buttons_value);
// Ensure the styles textarea exists and is initialized empty.
$styles_textarea = $this->xpath('//textarea[@name="editor[settings][plugins][stylescombo][styles]"]');
......@@ -275,7 +275,7 @@ public function testNewFormat() {
$ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
$default_settings = $ckeditor->getDefaultSettings();
$expected_buttons_value = json_encode($default_settings['toolbar']['rows']);
$this->assertFieldByName('editor[settings][toolbar][button_groups]', $expected_buttons_value);
$this->assertSession()->fieldValueEquals('editor[settings][toolbar][button_groups]', $expected_buttons_value);
// Regression test for https://www.drupal.org/node/2606460.
$settings = $this->getDrupalSettings();
......
......@@ -138,7 +138,8 @@ public function testAnonymous() {
$this->drupalLogin($this->adminUser);
$this->drupalGet('comment/' . $anonymous_comment3->id() . '/edit');
$this->assertRaw($author_name);
$this->assertFieldByName('uid', '', 'The author field is empty (i.e. anonymous) when editing the comment.');
// Check the author field is empty (i.e. anonymous) when editing the comment.
$this->assertSession()->fieldValueEquals('uid', '');
$this->assertRaw($author_mail);
// Unpublish comment.
......@@ -202,8 +203,8 @@ public function testAnonymous() {
$this->drupalGet('node/' . $this->node->id());
// Verify that comments were not displayed.
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.');
$this->assertSession()->fieldValueEquals('subject[0][value]', '');
$this->assertSession()->fieldValueEquals('comment_body[0][value]', '');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $anonymous_comment2->id());
$this->assertSession()->statusCodeEquals(403);
......
......@@ -140,7 +140,7 @@ public function postComment(EntityInterface $entity, $comment, $subject = '', $c
$edit['subject[0][value]'] = $subject;
}
else {
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
$this->assertSession()->fieldValueNotEquals('subject[0][value]', '');
}
if ($contact !== NULL && is_array($contact)) {
......@@ -149,19 +149,19 @@ public function postComment(EntityInterface $entity, $comment, $subject = '', $c
switch ($preview_mode) {
case DRUPAL_REQUIRED:
// Preview required so no save button should be found.
$this->assertNoFieldByName('op', t('Save'), 'Save button not found.');
$this->assertSession()->buttonNotExists(t('Save'));
$this->drupalPostForm(NULL, $edit, t('Preview'));
// Don't break here so that we can test post-preview field presence and
// function below.
case DRUPAL_OPTIONAL:
$this->assertFieldByName('op', t('Preview'), 'Preview button found.');
$this->assertFieldByName('op', t('Save'), 'Save button found.');
$this->assertSession()->buttonExists(t('Preview'));
$this->assertSession()->buttonExists(t('Save'));
$this->drupalPostForm(NULL, $edit, t('Save'));
break;
case DRUPAL_DISABLED:
$this->assertNoFieldByName('op', t('Preview'), 'Preview button not found.');
$this->assertFieldByName('op', t('Save'), 'Save button found.');
$this->assertSession()->buttonNotExists(t('Preview'));
$this->assertSession()->buttonExists(t('Save'));
$this->drupalPostForm(NULL, $edit, t('Save'));
break;
}
......@@ -361,8 +361,8 @@ public function testCommentFunctionality() {
// Attempt to view test entity comment form while disallowed.
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
$this->assertSession()->statusCodeEquals(403);
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.');
$this->assertSession()->fieldNotExists('subject[0][value]');
$this->assertSession()->fieldNotExists('comment_body[0][value]');
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
......@@ -375,8 +375,8 @@ public function testCommentFunctionality() {
$this->assertSession()->responseMatches('@<h2[^>]*>Comments</h2>@');
$this->assertSession()->linkExists('Log in', 0, 'Link to login was found.');
$this->assertSession()->linkExists('register', 0, 'Link to register was found.');
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.');
$this->assertSession()->fieldNotExists('subject[0][value]');
$this->assertSession()->fieldNotExists('comment_body[0][value]');
// Test the combination of anonymous users being able to post, but not view
// comments, to ensure that access to post comments doesn't grant access to
......@@ -390,8 +390,8 @@ public function testCommentFunctionality() {
$this->drupalGet('entity_test/' . $this->entity->id());
// Verify that comments were not displayed.
$this->assertSession()->responseNotMatches('@<h2[^>]*>Comments</h2>@');
$this->assertFieldByName('subject[0][value]', '', 'Subject field found.');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment field found.');
$this->assertSession()->fieldValueEquals('subject[0][value]', '');
$this->assertSession()->fieldValueEquals('comment_body[0][value]', '');
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment/' . $comment1->id());
$this->assertSession()->statusCodeEquals(403);
......@@ -419,7 +419,7 @@ public function testCommentFunctionality() {
$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);
$this->assertSession()->fieldValueEquals('settings[anonymous]', CommentInterface::ANONYMOUS_MAY_CONTACT);
// Add a new comment-type.
$bundle = CommentType::create([
......@@ -457,8 +457,8 @@ public function testCommentFunctionality() {
// @todo Check proper url and form https://www.drupal.org/node/2458323
$this->drupalGet('comment/reply/entity_test/comment/' . $new_entity->id());
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field found.');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field found.');
$this->assertSession()->fieldNotExists('subject[0][value]');
$this->assertSession()->fieldNotExists('comment_body[0][value]');
// Test removal of comment_body field.
$limited_user = $this->drupalCreateUser([
......@@ -471,10 +471,10 @@ public function testCommentFunctionality() {
$this->drupalLogin($limited_user);
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
$this->assertFieldByName('comment_body[0][value]', '', 'Comment body field found.');
$this->assertSession()->fieldValueEquals('comment_body[0][value]', '');
$this->fieldUIDeleteField('admin/structure/comment/manage/comment', 'comment.comment.comment_body', 'Comment', 'Comment settings');
$this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment');
$this->assertNoFieldByName('comment_body[0][value]', '', 'Comment body field not found.');
$this->assertSession()->fieldNotExists('comment_body[0][value]');
// Set subject field to autogenerate it.
$edit = ['subject[0][value]' => ''];
$this->drupalPostForm(NULL, $edit, t('Save'));
......
......@@ -72,8 +72,8 @@ public function testCommentPreview() {
$this->assertText($edit['comment_body[0][value]'], 'Comment displayed.');
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.');
$this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
$this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']);
$this->assertSession()->fieldValueEquals('comment_body[0][value]', $edit['comment_body[0][value]']);
// Check that the user picture is displayed.
$this->assertFieldByXPath("//article[contains(@class, 'preview')]//div[contains(@class, 'user-picture')]//img", NULL, 'User picture displayed.');
......@@ -106,8 +106,8 @@ public function testCommentPreviewDuplicateSubmission() {
$this->assertText($edit['comment_body[0][value]'], 'Comment displayed.');
// Check that the title and body fields are displayed with the correct values.
$this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.');
$this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
$this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']);
$this->assertSession()->fieldValueEquals('comment_body[0][value]', $edit['comment_body[0][value]']);
// Store the content of this page.
$this->drupalPostForm(NULL, [], 'Save');
......@@ -162,11 +162,11 @@ public function testCommentEditPreviewSave() {
$this->assertText($expected_text_date, 'Date displayed.');
// Check that the subject, comment, author and date fields are displayed with the correct values.
$this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.');
$this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
$this->assertFieldByName('uid', $edit['uid'], 'Author field displayed.');
$this->assertFieldByName('date[date]', $edit['date[date]'], 'Date field displayed.');
$this->assertFieldByName('date[time]', $edit['date[time]'], 'Time field displayed.');
$this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']);
$this->assertSession()->fieldValueEquals('comment_body[0][value]', $edit['comment_body[0][value]']);
$this->assertSession()->fieldValueEquals('uid', $edit['uid']);
$this->assertSession()->fieldValueEquals('date[date]', $edit['date[date]']);
$this->assertSession()->fieldValueEquals('date[time]', $edit['date[time]']);
// Check that saving a comment produces a success message.
$this->drupalPostForm('comment/' . $comment->id() . '/edit', $edit, t('Save'));
......@@ -174,11 +174,11 @@ public function testCommentEditPreviewSave() {
// Check that the comment fields are correct after loading the saved comment.
$this->drupalGet('comment/' . $comment->id() . '/edit');
$this->assertFieldByName('subject[0][value]', $edit['subject[0][value]'], 'Subject field displayed.');
$this->assertFieldByName('comment_body[0][value]', $edit['comment_body[0][value]'], 'Comment field displayed.');
$this->assertFieldByName('uid', $edit['uid'], 'Author field displayed.');
$this->assertFieldByName('date[date]', $expected_form_date, 'Date field displayed.');
$this->assertFieldByName('date[time]', $expected_form_time, 'Time field displayed.');
$this->assertSession()->fieldValueEquals('subject[0][value]', $edit['subject[0][value]']);
$this->assertSession()->fieldValueEquals('comment_body[0][value]', $edit['comment_body[0][value]']);
$this->assertSession()->fieldValueEquals('uid', $edit['uid']);
$this->assertSession()->fieldValueEquals('date[date]', $expected_form_date);
$this->assertSession()->fieldValueEquals('date[time]', $expected_form_time);
// Submit the form using the displayed values.
$displayed = [];
......
......@@ -139,7 +139,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $
$edit['subject[0][value]'] = $subject;
}
else {
$this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
$this->assertSession()->fieldNotExists('subject[0][value]');
}
if ($contact !== NULL && is_array($contact)) {
......@@ -148,19 +148,19 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $
switch ($preview_mode) {
case DRUPAL_REQUIRED:
// Preview required so no save button should be found.
$this->assertNoFieldByName('op', t('Save'), 'Save button not found.');
$this->assertSession()->buttonNotExists(t('Save'));
$this->drupalPostForm(NULL, $edit, t('Preview'));
// Don't break here so that we can test post-preview field presence and
// function below.
case DRUPAL_OPTIONAL:
$this->assertFieldByName('op', t('Preview'), 'Preview button found.');
$this->assertFieldByName('op', t('Save'), 'Save button found.');
$this->assertSession()->buttonExists(t('Preview'));
$this->assertSession()->buttonExists(t('Save'));
$this->drupalPostForm(NULL, $edit, t('Save'));
break;
case DRUPAL_DISABLED:
$this->assertNoFieldByName('op', t('Preview'), 'Preview button not found.');
$this->assertFieldByName('op', t('Save'), 'Save button found.');
$this->assertSession()->buttonNotExists(t('Preview'));
$this->assertSession()->buttonExists(t('Save'));
$this->drupalPostForm(NULL, $edit, t('Save'));
break;
}
......
......@@ -328,12 +328,12 @@ public function testCRUDUI() {
'size' => 'custom',
];
$this->assertFieldByName('size');
$this->assertNoFieldByName('size_value');
$this->assertSession()->fieldExists('size');
$this->assertSession()->fieldNotExists('size_value');
$this->drupalPostForm(NULL, $edit, 'Change size');
$this->assertFieldByName('size');
$this->assertFieldByName('size_value');
$this->assertSession()->fieldExists('size');
$this->assertSession()->fieldExists('size_value');
// Submit the form with the regular 'Save' button and check that the entity
// values are correct.
......
......@@ -136,7 +136,7 @@ public function testExportImport() {
->save();
$this->drupalGet('node/add/' . $this->contentType->id());
$this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed');
$this->assertSession()->fieldValueEquals("{$this->fieldName}[0][value]", '');
// Export the configuration.
$this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export');
......@@ -161,7 +161,7 @@ public function testExportImport() {
}
}
$this->drupalGet('node/add/' . $this->contentType->id());
$this->assertNoFieldByName("{$this->fieldName}[0][value]", '', 'Widget is not displayed');
$this->assertSession()->fieldNotExists("{$this->fieldName}[0][value]");
// Import the configuration.
$filename = 'temporary://' . $this->randomMachineName();
......@@ -180,7 +180,7 @@ public function testExportImport() {
$this->assertEquals($this->newSlogan, $this->config('system.site')->get('slogan'));
$this->drupalGet('node/add');
$this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed');
$this->assertSession()->fieldValueEquals("{$this->fieldName}[0][value]", '');
$this->config('system.site')
->set('slogan', $this->originalSlogan)
......
......@@ -47,7 +47,7 @@ public function testFormWithOverride() {
$this->assertText('Path prefix configuration', 'Language-negotiation form found for English.');
// The English override should not be found.
$this->assertNoFieldByName('prefix[en]', $overridden_value_en, 'Language-negotiation config override not found in English.');
$this->assertSession()->fieldValueNotEquals('prefix[en]', $overridden_value_en);
// Now check the Spanish version of the page for the same thing.
$this->drupalGet($overridden_value_es . '/admin/config/regional/language/detection/url');
......@@ -56,7 +56,7 @@ public function testFormWithOverride() {
$this->assertText('Path prefix configuration', 'Language-negotiation form found for Spanish using the overridden prefix.');
// The Spanish override should not be found.
$this->assertNoFieldByName('prefix[es]', $overridden_value_es, 'Language-negotiation config override not found in Spanish.');
$this->assertSession()->fieldValueNotEquals('prefix[es]', $overridden_value_es);
}
......
......@@ -180,8 +180,8 @@ public function testSiteInformationTranslationUi() {
// Check translation saved proper.
$this->drupalGet("$translation_base_url/fr/edit");
$this->assertFieldByName('translation[config_names][system.site][name]', $fr_site_name);
$this->assertFieldByName('translation[config_names][system.site][slogan]', $fr_site_slogan);
$this->assertSession()->fieldValueEquals('translation[config_names][system.site][name]', $fr_site_name);
$this->assertSession()->fieldValueEquals('translation[config_names][system.site][slogan]', $fr_site_slogan);
// Place branding block with site name and slogan into header region.
$this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
......@@ -390,7 +390,7 @@ public function testContactConfigEntityTranslation() {
$langcode_prefixes = array_merge([''], $this->langcodes);
foreach ($langcode_prefixes as $langcode_prefix) {
$this->drupalGet(ltrim("$langcode_prefix/$translation_base_url/$langcode/edit", '/'));
$this->assertFieldByName('translation[config_names][contact.form.feedback][label]', 'Website feedback - ' . $langcode);
$this->assertSession()->fieldValueEquals('translation[config_names][contact.form.feedback][label]', 'Website feedback - ' . $langcode);
$this->assertText($label);
}
}
......@@ -628,10 +628,10 @@ public function testViewsTranslationUI() {
// Check translation saved proper.
$this->drupalGet("$translation_base_url/fr/edit");
$this->assertFieldByName('translation[config_names][views.view.frontpage][description]', $description . " FR");
$this->assertFieldByName('translation[config_names][views.view.frontpage][label]', $human_readable_name . " FR");
$this->assertFieldByName('translation[config_names][views.view.frontpage][display][default][display_title]', $display_settings_master . " FR");
$this->assertFieldByName('translation[config_names][views.view.frontpage][display][default][display_options][title]', $display_options_master . " FR");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.frontpage][description]', $description . " FR");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.frontpage][label]', $human_readable_name . " FR");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.frontpage][display][default][display_title]', $display_settings_master . " FR");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.frontpage][display][default][display_options][title]', $display_options_master . " FR");
}
/**
......@@ -702,10 +702,10 @@ public function testPluralConfigStrings() {
// Make sure original text is present on this page, in addition to 2 new
// empty fields.
$this->assertRaw($description);
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][0]', $field_value);
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][1]', $field_value_plural);
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][2]', '');
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][3]', '');
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][0]', $field_value);
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][1]', $field_value_plural);
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][2]', '');
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][3]', '');
// Then make sure it also works.
$edit = [
......@@ -718,10 +718,10 @@ public function testPluralConfigStrings() {
// Make sure the values have changed.
$this->drupalGet($translation_url);
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][0]', "$field_value SL");
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][1]', "$field_value_plural 1 SL");
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][2]', "$field_value_plural 2 SL");
$this->assertFieldByName('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][3]', "$field_value_plural 3 SL");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][0]', "$field_value SL");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][1]', "$field_value_plural 1 SL");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][2]', "$field_value_plural 2 SL");
$this->assertSession()->fieldValueEquals('translation[config_names][views.view.files][display][default][display_options][fields][count][format_plural_string][3]', "$field_value_plural 3 SL");
}
/**
......@@ -969,7 +969,7 @@ public function testTextFormatTranslation() {
// Assert that changing the text format is not possible, even for an
// administrator.
$this->assertNoFieldByName('translation[config_names][config_translation_test.content][content][format]');
$this->assertSession()->fieldNotExists('translation[config_names][config_translation_test.content][content][format]');
// Update translatable fields.
$edit = [
......
......@@ -289,7 +289,7 @@ public function testSiteWideContact() {
$this->drupalGet('admin/structure/contact');
$this->clickLink(t('Edit'));
$this->assertSession()->statusCodeEquals(200);
$this->assertFieldByName('label', $label);
$this->assertSession()->fieldValueEquals('label', $label);
// Test field UI and field integration.
$this->drupalGet('admin/structure/contact');
......
......@@ -126,7 +126,7 @@ public function testModerationForm() {
// Check widget default value.
$this->drupalGet($edit_path);
$this->assertFieldByName('moderation_state[0][state]', 'published', 'The moderation default value is set correctly.');
$this->assertSession()->fieldValueEquals('moderation_state[0][state]', 'published');
// Preview the content while selecting the "draft" state and when the user
// returns to the edit form, ensure all of the available transitions are
......
......@@ -239,7 +239,7 @@ public function testAccountLanguageSettingsUI() {
// Make sure account settings can be saved.
$this->drupalPostForm('admin/config/people/accounts', ['anonymous' => 'Save me please!'], 'Save configuration');
$this->assertFieldByName('anonymous', 'Save me please!', 'Anonymous name has been changed.');
$this->assertSession()->fieldValueEquals('anonymous', 'Save me please!');
$this->assertText('The configuration options have been saved.');
}
......
......@@ -54,9 +54,9 @@ public function testDateField() {
// Display creation form.
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value][date]", '', 'Date element found.');
$this->assertSession()->fieldValueEquals("{$field_name}[0][value][date]", '');
$this->assertFieldByXPath('//*[@id="edit-' . $field_name . '-wrapper"]//label[contains(@class,"js-form-required")]', TRUE, 'Required markup found');
$this->assertNoFieldByName("{$field_name}[0][value][time]", '', 'Time element not found.');
$this->assertSession()->fieldNotExists("{$field_name}[0][value][time]");
$this->assertFieldByXPath('//input[@aria-describedby="edit-' . $field_name . '-0-value--description"]', NULL, 'ARIA described-by found');
$this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0-value--description"]', NULL, 'ARIA description found');
......@@ -247,8 +247,8 @@ public function testDatetimeField() {
// Display creation form.
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value][date]", '', 'Date element found.');
$this->assertFieldByName("{$field_name}[0][value][time]", '', 'Time element found.');
$this->assertSession()->fieldValueEquals("{$field_name}[0][value][date]", '');
$this->assertSession()->fieldValueEquals("{$field_name}[0][value][time]", '');
$this->assertFieldByXPath('//fieldset[@id="edit-' . $field_name . '-0"]/legend', $field_label, 'Fieldset and label found');
$this->assertFieldByXPath('//fieldset[@aria-describedby="edit-' . $field_name . '-0--description"]', NULL, 'ARIA described-by found');
$this->assertFieldByXPath('//div[@id="edit-' . $field_name . '-0--description"]', NULL, 'ARIA description found');
......@@ -697,7 +697,8 @@ public function testDefaultValue() {
// Check that default value is selected in default value form.
$this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name);
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-date-type', 'now')->isSelected());
$this->assertFieldByName('default_value_input[default_date]', '', 'The relative default value is empty in instance settings page');
// Check that the relative default value is empty.
$this->assertSession()->fieldValueEquals('default_value_input[default_date]', '');
// Check if default_date has been stored successfully.
$config_entity = $this->config('field.field.node.date_content.' . $field_name)
......@@ -735,7 +736,8 @@ public function testDefaultValue() {
// Check that default value is selected in default value form.
$this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name);
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-date-type', 'relative')->isSelected());
$this->assertFieldByName('default_value_input[default_date]', '+90 days', 'The relative default value is displayed in instance settings page');
// Check that the relative default value is displayed.
$this->assertSession()->fieldValueEquals('default_value_input[default_date]', '+90 days');
// Check if default_date has been stored successfully.
$config_entity = $this->config('field.field.node.date_content.' . $field_name)
......@@ -764,7 +766,8 @@ public function testDefaultValue() {
// Check that default value is selected in default value form.
$this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name);
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-date-type', '')->isSelected());
$this->assertFieldByName('default_value_input[default_date]', '', 'The relative default value is empty in instance settings page');
// Check that the relative default value is empty.
$this->assertSession()->fieldValueEquals('default_value_input[default_date]', '');
// Check if default_date has been stored successfully.
$config_entity = $this->config('field.field.node.date_content.' . $field_name)
......@@ -792,8 +795,8 @@ public function testInvalidField() {
// Display creation form.
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value][date]", '', 'Date element found.');
$this->assertFieldByName("{$field_name}[0][value][time]", '', 'Time element found.');
$this->assertSession()->fieldValueEquals("{$field_name}[0][value][date]", '');
$this->assertSession()->fieldValueEquals("{$field_name}[0][value][time]", '');
// Submit invalid dates and ensure they is not accepted.
$date_value = '';
......
......@@ -66,11 +66,11 @@ public function testDateRangeField() {
// Display creation form.
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value][date]", '', 'Start date element found.');
$this->assertFieldByName("{$field_name}[0][end_value][date]", '', 'End date element found.');
$this->assertSession()->fieldValueEquals("