Commit 488b2cee authored by catch's avatar catch
Browse files

Issue #3139426 by jungle, rajandro, mohrerao, sja112, mondrake: Replace usages...

Issue #3139426 by jungle, rajandro, mohrerao, sja112, mondrake: Replace usages of deprecated AssertLegacyTrait::assertOptionSelected()
parent c114930c
......@@ -132,16 +132,8 @@ public function testBlockAdminUiPage() {
$this->drupalPostForm('admin/structure/block', $edit, t('Save blocks'));
foreach ($this->blockValues as $values) {
// Check if the region and weight settings changes have persisted.
$this->assertOptionSelected(
'edit-blocks-' . $values['settings']['id'] . '-region',
'header',
'The block "' . $label . '" has the correct region assignment (header).'
);
$this->assertOptionSelected(
'edit-blocks-' . $values['settings']['id'] . '-weight',
$values['test_weight'],
'The block "' . $label . '" has the correct weight assignment (' . $values['test_weight'] . ').'
);
$this->assertTrue($this->assertSession()->optionExists('edit-blocks-' . $values['settings']['id'] . '-region', 'header')->isSelected());
$this->assertTrue($this->assertSession()->optionExists('edit-blocks-' . $values['settings']['id'] . '-weight', $values['test_weight'])->isSelected());
}
// Add a block with a machine name the same as a region name.
......
......@@ -432,7 +432,8 @@ public function testBookOutline() {
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/' . $empty_book->id() . '/outline');
$this->assertRaw(t('Book outline'));
$this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book');
// Verify that the node does not belong to a book.
$this->assertTrue($this->assertSession()->optionExists('edit-book-bid', 0)->isSelected());
$this->assertSession()->linkNotExists(t('Remove from book outline'));
$edit = [];
......@@ -472,7 +473,7 @@ public function testBookOutline() {
// Test the form itself.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertOptionSelected('edit-book-bid', $node->id());
$this->assertTrue($this->assertSession()->optionExists('edit-book-bid', $node->id())->isSelected());
}
/**
......
......@@ -459,23 +459,23 @@ public function testDatelistWidget() {
$this->drupalGet('entity_test/add');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-year\"]", NULL, 'Year element found.');
$this->assertOptionSelected("edit-$field_name-0-value-year", '', 'No year selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '')->isSelected());
$this->assertSession()->optionExists("edit-$field_name-0-value-year", 'Year');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-month\"]", NULL, 'Month element found.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '', 'No month selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '')->isSelected());
$this->assertSession()->optionExists("edit-$field_name-0-value-month", 'Month');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-day\"]", NULL, 'Day element found.');
$this->assertOptionSelected("edit-$field_name-0-value-day", '', 'No day selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-day", '')->isSelected());
$this->assertSession()->optionExists("edit-$field_name-0-value-day", 'Day');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-hour\"]", NULL, 'Hour element found.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '', 'No hour selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-hour", '')->isSelected());
$this->assertSession()->optionExists("edit-$field_name-0-value-hour", 'Hour');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-minute\"]", NULL, 'Minute element found.');
$this->assertOptionSelected("edit-$field_name-0-value-minute", '', 'No minute selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-minute", '')->isSelected());
$this->assertSession()->optionExists("edit-$field_name-0-value-minute", 'Minute');
$this->assertNoFieldByXPath("//*[@id=\"edit-$field_name-0-value-second\"]", NULL, 'Second element not found.');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-ampm\"]", NULL, 'AMPM element found.');
$this->assertOptionSelected("edit-$field_name-0-value-ampm", '', 'No ampm selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-ampm", '')->isSelected());
$this->assertSession()->optionExists("edit-$field_name-0-value-ampm", 'AM/PM');
// Submit a valid date and ensure it is accepted.
......@@ -493,12 +493,12 @@ public function testDatelistWidget() {
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.');
$this->assertOptionSelected("edit-$field_name-0-value-day", '31', 'Correct day selected.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '5', 'Correct hour selected.');
$this->assertOptionSelected("edit-$field_name-0-value-minute", '15', 'Correct minute selected.');
$this->assertOptionSelected("edit-$field_name-0-value-ampm", 'am', 'Correct ampm selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-day", '31')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-hour", '5')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-minute", '15')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-ampm", 'am')->isSelected());
// Test the widget using increment other than 1 and 24 hour mode.
$display_repository->getFormDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle())
......@@ -518,9 +518,8 @@ public function testDatelistWidget() {
// Other elements are unaffected by the changed settings.
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-hour\"]", NULL, 'Hour element found.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '', 'No hour selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-hour", '')->isSelected());
$this->assertNoFieldByXPath("//*[@id=\"edit-$field_name-0-value-ampm\"]", NULL, 'AMPM element not found.');
// Submit a valid date and ensure it is accepted.
$date_value = ['year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 17, 'minute' => 15];
......@@ -534,11 +533,11 @@ public function testDatelistWidget() {
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.');
$this->assertOptionSelected("edit-$field_name-0-value-day", '31', 'Correct day selected.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '17', 'Correct hour selected.');
$this->assertOptionSelected("edit-$field_name-0-value-minute", '15', 'Correct minute selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-day", '31')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-hour", '17')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-minute", '15')->isSelected());
// Test the widget for partial completion of fields.
$display_repository->getFormDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle())
......@@ -599,7 +598,7 @@ public function testDatelistWidget() {
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertSession()->statusCodeEquals(200);
$this->assertOptionSelected("edit-$field_name-0-value-minute", '0', 'Correct minute selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-minute", '0')->isSelected());
}
/**
......@@ -697,7 +696,7 @@ 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->assertOptionSelected('edit-default-value-input-default-date-type', 'now', 'The default value is selected in instance settings page');
$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 if default_date has been stored successfully.
......@@ -735,7 +734,7 @@ 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->assertOptionSelected('edit-default-value-input-default-date-type', 'relative', 'The default value is selected in instance settings page');
$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 if default_date has been stored successfully.
......@@ -764,7 +763,7 @@ 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->assertOptionSelected('edit-default-value-input-default-date-type', '', 'The default value is selected in instance settings page');
$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 if default_date has been stored successfully.
......
......@@ -748,7 +748,7 @@ public function testDatelistWidget() {
foreach (['value', 'end-value'] as $column) {
foreach (['year', 'month', 'day', 'hour', 'minute', 'ampm'] as $element) {
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-$column-$element\"]", NULL, $element . ' element found.');
$this->assertOptionSelected("edit-$field_name-0-$column-$element", '', 'No ' . $element . ' selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-$column-$element", '')->isSelected());
}
}
......@@ -772,19 +772,19 @@ public function testDatelistWidget() {
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.');
$this->assertOptionSelected("edit-$field_name-0-value-day", '31', 'Correct day selected.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '5', 'Correct hour selected.');
$this->assertOptionSelected("edit-$field_name-0-value-minute", '15', 'Correct minute selected.');
$this->assertOptionSelected("edit-$field_name-0-value-ampm", 'am', 'Correct ampm selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-day", '31')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-hour", '5')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-minute", '15')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-ampm", 'am')->isSelected());
$this->assertOptionSelected("edit-$field_name-0-end-value-year", '2013', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-month", '1', 'Correct month selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-day", '15', 'Correct day selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-hour", '3', 'Correct hour selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-minute", '30', 'Correct minute selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-ampm", 'pm', 'Correct ampm selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-year", '2013')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-month", '1')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-day", '15')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-hour", '3')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-minute", '30')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-ampm", 'pm')->isSelected());
// Test the widget using increment other than 1 and 24 hour mode.
$display_repository->getFormDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle())
......@@ -804,10 +804,10 @@ public function testDatelistWidget() {
// Other elements are unaffected by the changed settings.
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-value-hour\"]", NULL, 'Hour element found.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '', 'No hour selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-hour", '')->isSelected());
$this->assertNoFieldByXPath("//*[@id=\"edit-$field_name-0-value-ampm\"]", NULL, 'AMPM element not found.');
$this->assertFieldByXPath("//*[@id=\"edit-$field_name-0-end-value-hour\"]", NULL, 'Hour element found.');
$this->assertOptionSelected("edit-$field_name-0-end-value-hour", '', 'No hour selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-hour", '')->isSelected());
$this->assertNoFieldByXPath("//*[@id=\"edit-$field_name-0-end-value-ampm\"]", NULL, 'AMPM element not found.');
// Submit a valid date and ensure it is accepted.
......@@ -827,17 +827,17 @@ public function testDatelistWidget() {
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
$this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.');
$this->assertOptionSelected("edit-$field_name-0-value-day", '31', 'Correct day selected.');
$this->assertOptionSelected("edit-$field_name-0-value-hour", '17', 'Correct hour selected.');
$this->assertOptionSelected("edit-$field_name-0-value-minute", '15', 'Correct minute selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '2012')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '12')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-day", '31')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-hour", '17')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-minute", '15')->isSelected());
$this->assertOptionSelected("edit-$field_name-0-end-value-year", '2013', 'Correct year selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-month", '1', 'Correct month selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-day", '15', 'Correct day selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-hour", '3', 'Correct hour selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-minute", '30', 'Correct minute selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-year", '2013')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-month", '1')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-day", '15')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-hour", '3')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-minute", '30')->isSelected());
// Test the widget for partial completion of fields.
$display_repository->getFormDisplay($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle())
......@@ -909,8 +909,8 @@ public function testDatelistWidget() {
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertSession()->statusCodeEquals(200);
$this->assertOptionSelected("edit-$field_name-0-value-minute", '0', 'Correct minute selected.');
$this->assertOptionSelected("edit-$field_name-0-end-value-minute", '0', 'Correct minute selected.');
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-minute", '0')->isSelected());
$this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-end-value-minute", '0')->isSelected());
}
/**
......@@ -1024,9 +1024,9 @@ 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->assertOptionSelected('edit-default-value-input-default-date-type', 'now', 'The default start value is selected in instance settings page');
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-date-type', 'now')->isSelected());
$this->assertFieldByName('default_value_input[default_date]', '', 'The relative start default value is empty in instance settings page');
$this->assertOptionSelected('edit-default-value-input-default-end-date-type', 'now', 'The default end value is selected in instance settings page');
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-end-date-type', 'now')->isSelected());
$this->assertFieldByName('default_value_input[default_end_date]', '', 'The relative end default value is empty in instance settings page');
// Check if default_date has been stored successfully.
......@@ -1077,9 +1077,9 @@ 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->assertOptionSelected('edit-default-value-input-default-date-type', 'relative', 'The default start value is selected in instance settings page');
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-date-type', 'relative')->isSelected());
$this->assertFieldByName('default_value_input[default_date]', '+45 days', 'The relative default start value is displayed in instance settings page');
$this->assertOptionSelected('edit-default-value-input-default-end-date-type', 'relative', 'The default end value is selected in instance settings page');
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-end-date-type', 'relative')->isSelected());
$this->assertFieldByName('default_value_input[default_end_date]', '+90 days', 'The relative default end value is displayed in instance settings page');
// Check if default_date has been stored successfully.
......@@ -1110,9 +1110,9 @@ 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->assertOptionSelected('edit-default-value-input-default-date-type', '', 'The default start value is selected in instance settings page');
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-date-type', '')->isSelected());
$this->assertFieldByName('default_value_input[default_date]', '', 'The relative default start value is empty in instance settings page');
$this->assertOptionSelected('edit-default-value-input-default-end-date-type', '', 'The default end value is selected in instance settings page');
$this->assertTrue($this->assertSession()->optionExists('edit-default-value-input-default-end-date-type', '')->isSelected());
$this->assertFieldByName('default_value_input[default_end_date]', '', 'The relative default end value is empty in instance settings page');
// Check if default_date has been stored successfully.
......
......@@ -72,7 +72,7 @@ public function testHandlerUI() {
$this->drupalPostForm(NULL, ['options[type]' => 'text_trimmed'], t('Apply'));
$this->drupalGet($url);
$this->assertOptionSelected('edit-options-type', 'text_trimmed');
$this->assertTrue($this->assertSession()->optionExists('edit-options-type', 'text_trimmed')->isSelected());
$random_number = rand(100, 400);
$this->drupalPostForm(NULL, ['options[settings][trim_length]' => $random_number], t('Apply'));
......
......@@ -231,7 +231,7 @@ protected function assertOptions($id, array $expected_options, $selected) {
]));
}
$this->assertOptionSelected($id, $selected);
$this->assertTrue($this->assertSession()->optionExists($id, $selected)->isSelected());
}
/**
......
......@@ -57,7 +57,7 @@ public function testLanguageConfigurationElement() {
$this->assertEqual($lang_conf->getDefaultLangcode(), 'current_interface');
$this->assertFalse($lang_conf->isLanguageAlterable());
$this->drupalGet('language-tests/language_configuration_element');
$this->assertOptionSelected('edit-lang-configuration-langcode', 'current_interface');
$this->assertTrue($this->assertSession()->optionExists('edit-lang-configuration-langcode', 'current_interface')->isSelected());
$this->assertNoFieldChecked('edit-lang-configuration-language-alterable');
// Reload the page and save again.
......@@ -71,7 +71,7 @@ public function testLanguageConfigurationElement() {
$this->assertEqual($lang_conf->getDefaultLangcode(), 'authors_default');
$this->assertTrue($lang_conf->isLanguageAlterable());
$this->drupalGet('language-tests/language_configuration_element');
$this->assertOptionSelected('edit-lang-configuration-langcode', 'authors_default');
$this->assertTrue($this->assertSession()->optionExists('edit-lang-configuration-langcode', 'authors_default')->isSelected());
$this->assertFieldChecked('edit-lang-configuration-language-alterable');
// Test if content type settings have been saved.
......@@ -85,7 +85,7 @@ public function testLanguageConfigurationElement() {
// Make sure the settings are saved when creating the content type.
$this->drupalGet('admin/structure/types/manage/page');
$this->assertOptionSelected('edit-language-configuration-langcode', 'authors_default');
$this->assertTrue($this->assertSession()->optionExists('edit-language-configuration-langcode', 'authors_default')->isSelected());
$this->assertFieldChecked('edit-language-configuration-language-alterable');
}
......@@ -159,7 +159,7 @@ public function testDefaultLangcode() {
->save();
$this->drupalGet('language-tests/language_configuration_element_test');
$this->assertOptionSelected('edit-langcode', 'bb');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode', 'bb')->isSelected());
}
/**
......
......@@ -73,7 +73,7 @@ public function testMenuLanguage() {
->save();
// Check menu language.
$this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The menu language was correctly selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode', $edit['langcode'])->isSelected());
// Test menu link language.
$link_path = '/';
......@@ -132,7 +132,7 @@ public function testMenuLanguage() {
// page first.
$this->drupalGet('admin/structure/menu/item/' . $menu_link->id() . '/edit');
// Check that the language selector has the correct default value.
$this->assertOptionSelected('edit-langcode-0-value', 'bb', 'The menu link language was correctly selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'bb')->isSelected());
// Edit menu to hide the language select on menu link item add.
ContentLanguageSettings::loadByEntityTypeBundle('menu_link_content', 'menu_link_content')
......
......@@ -45,7 +45,7 @@ protected function setUp(): void {
*/
public function testNodeTypeInitialLanguageDefaults() {
$this->drupalGet('admin/structure/types/manage/article');
$this->assertOptionSelected('edit-language-configuration-langcode', LanguageInterface::LANGCODE_SITE_DEFAULT, 'The default initial language is the site default.');
$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.');
// Tests if the language field cannot be rearranged on the manage fields tab.
......@@ -74,7 +74,7 @@ public function testNodeTypeInitialLanguageDefaults() {
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->drupalGet('node/add/article');
$this->assertField('langcode[0][value]', 'Language is selectable on node add/edit page when language not hidden.');
$this->assertOptionSelected('edit-langcode-0-value', 'hu', 'The initial language is the site default on the node add page after the site default language is changed.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'hu')->isSelected());
// Tests if the language field can be rearranged on the manage form display
// tab.
......@@ -87,7 +87,7 @@ public function testNodeTypeInitialLanguageDefaults() {
$language_display = $this->xpath('//*[@id="langcode"]');
$this->assert(!empty($language_display), 'Language field is visible on manage display tab.');
// Tests if the language field is hidden by default.
$this->assertOptionSelected('edit-fields-langcode-region', 'hidden', 'Language is hidden by default on manage display tab.');
$this->assertTrue($this->assertSession()->optionExists('edit-fields-langcode-region', 'hidden')->isSelected());
// Changes the initial language settings.
$edit = [
......@@ -95,7 +95,7 @@ public function testNodeTypeInitialLanguageDefaults() {
];
$this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->drupalGet('node/add/article');
$this->assertOptionSelected('edit-langcode-0-value', 'en', 'The initial language is the defined language.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'en')->isSelected());
}
/**
......@@ -125,7 +125,7 @@ public function testLanguageFieldVisibility() {
];
$this->drupalPostForm('admin/structure/types/manage/article/display', $edit, t('Save'));
$this->drupalGet('admin/structure/types/manage/article/display');
$this->assertOptionSelected('edit-fields-langcode-type', 'language', 'Language field has been set to visible.');
$this->assertTrue($this->assertSession()->optionExists('edit-fields-langcode-type', 'language')->isSelected());
// Loads node page and check if Language field is shown.
$this->drupalGet('node/' . $node->id());
......
......@@ -215,7 +215,7 @@ public function testRequiredCheckboxesRadio() {
$this->assertFieldByName('textfield', '');
$this->assertNoFieldChecked('edit-checkboxes-foo');
$this->assertNoFieldChecked('edit-checkboxes-bar');
$this->assertOptionSelected('edit-select', '');
$this->assertTrue($this->assertSession()->optionExists('edit-select', '')->isSelected());
$this->assertNoFieldChecked('edit-radios-foo');
$this->assertNoFieldChecked('edit-radios-bar');
$this->assertNoFieldChecked('edit-radios-optional-foo');
......@@ -270,7 +270,7 @@ public function testInputWithInvalidToken() {
$this->assertFieldByName('textfield', '');
$this->assertNoFieldChecked('edit-checkboxes-foo');
$this->assertNoFieldChecked('edit-checkboxes-bar');
$this->assertOptionSelected('edit-select', '');
$this->assertTrue($this->assertSession()->optionExists('edit-select', '')->isSelected());
$this->assertNoFieldChecked('edit-radios-foo');
// Check another form that has a textarea input.
......
......@@ -272,7 +272,7 @@ public function testUpdatedSite() {
$this->drupalGet('admin/config/regional/date-time');
$this->assertText('Test date format');
$this->drupalGet('admin/config/regional/date-time/formats/manage/test_date_format');
$this->assertOptionSelected('edit-langcode', 'es');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode', 'es')->isSelected());
// Make sure our custom image style exists.
$this->drupalGet('admin/config/media/image-styles/manage/test_image_style');
......
......@@ -67,7 +67,7 @@ public function testTermLanguage() {
// Check if on the edit page the language is correct.
$this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
$this->assertOptionSelected('edit-langcode-0-value', $edit['langcode[0][value]'], 'The term language was correctly selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', $edit['langcode[0][value]'])->isSelected());
// Change the language of the term.
$edit['langcode[0][value]'] = 'bb';
......@@ -75,7 +75,7 @@ public function testTermLanguage() {
// Check again that on the edit page the language is correct.
$this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
$this->assertOptionSelected('edit-langcode-0-value', $edit['langcode[0][value]'], 'The term language was correctly selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', $edit['langcode[0][value]'])->isSelected());
}
public function testDefaultTermLanguage() {
......@@ -87,7 +87,7 @@ public function testDefaultTermLanguage() {
];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), $edit, t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
$this->assertOptionSelected('edit-langcode-0-value', 'bb', 'The expected langcode was selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'bb')->isSelected());
// Make the default language of the terms to be the current interface.
$edit = [
......@@ -96,9 +96,9 @@ public function testDefaultTermLanguage() {
];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), $edit, t('Save'));
$this->drupalGet('aa/admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
$this->assertOptionSelected('edit-langcode-0-value', 'aa', "The expected langcode, 'aa', was selected.");
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'aa')->isSelected());
$this->drupalGet('bb/admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
$this->assertOptionSelected('edit-langcode-0-value', 'bb', "The expected langcode, 'bb', was selected.");
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'bb')->isSelected());
// Change the default language of the site and check if the default terms
// language is still correctly selected.
......@@ -109,7 +109,7 @@ public function testDefaultTermLanguage() {
];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), $edit, t('Save'));
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add');
$this->assertOptionSelected('edit-langcode-0-value', 'cc', "The expected langcode, 'cc', was selected.");
$this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', 'cc')->isSelected());
}
/**
......
......@@ -56,7 +56,7 @@ public function testVocabularyLanguage() {
// Check the language on the edit page.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
$this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode', $edit['langcode'])->isSelected());
// Change the language and save again.
$edit['langcode'] = 'bb';
......@@ -65,7 +65,7 @@ public function testVocabularyLanguage() {
// Check again the language on the edit page.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
$this->assertOptionSelected('edit-langcode', $edit['langcode'], 'The vocabulary language was correctly selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-langcode', $edit['langcode'])->isSelected());
}
/**
......@@ -93,7 +93,7 @@ public function testVocabularyDefaultLanguageForTerms() {
$this->assertTrue($language_settings->isLanguageAlterable(), 'The visibility setting was saved.');
// Check that the correct options are selected in the interface.
$this->assertOptionSelected('edit-default-language-langcode', 'bb', 'The correct default language for the terms of this vocabulary is selected.');
$this->assertTrue($this->assertSession()->optionExists('edit-default-language-langcode', 'bb')->isSelected());
$this->assertFieldChecked('edit-default-language-language-alterable', 'Show language selection option is checked.');
// Edit the vocabulary and check that the new settings are updated.
......@@ -109,7 +109,7 @@ public function testVocabularyDefaultLanguageForTerms() {
$this->assertFalse($language_settings->isLanguageAlterable(), 'The visibility setting was saved.');
$this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
$this->assertOptionSelected('edit-default-language-langcode', 'aa', 'The correct default language for the terms of this vocabulary is selected.');
$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.');
// Check that language settings are changed after editing vocabulary.
......
......@@ -51,7 +51,7 @@ public function testLocalUserCreation() {
// Check if the language selector is available on admin/people/create and
// set to the currently active language.
$this->drupalGet($langcode . '/admin/people/create');
$this->assertOptionSelected("edit-preferred-langcode", $langcode, 'Global language set in the language selector.');
$this->assertTrue($this->assertSession()->optionExists("edit-preferred-langcode", $langcode)->isSelected());
// Create a user with the admin/people/create form and check if the correct
// language is set.
......@@ -93,7 +93,7 @@ public function testLocalUserCreation() {