Commit 68a59ee3 authored by xjm's avatar xjm
Browse files

Issue #3139421 by mondrake, mrinalini9, daffie: Replace usages of deprecated...

Issue #3139421 by mondrake, mrinalini9, daffie: Replace usages of deprecated AssertLegacyTrait::assert(No)Option()
parent 8b9b1304
......@@ -130,8 +130,10 @@ public function testBlockContentCreationMultipleViewModes() {
$this->drupalGet('admin/structure/block/manage/testblock');
// Test the available view mode options.
$this->assertOption('edit-settings-view-mode', 'default', 'The default view mode is available.');
$this->assertOption('edit-settings-view-mode', 'test_view_mode', 'The test view mode is available.');
// Verify that the default view mode is available.
$this->assertSession()->optionExists('edit-settings-view-mode', 'default');
// Verify that the test view mode is available.
$this->assertSession()->optionExists('edit-settings-view-mode', 'test_view_mode');
$view_mode['settings[view_mode]'] = 'test_view_mode';
$this->drupalPostForm(NULL, $view_mode, t('Save block'));
......
......@@ -295,10 +295,10 @@ public function testGetTableOfContents() {
$this->drupalGet($nodes[0]->toUrl('edit-form'));
// Since Node 0 has children 2 levels deep, nodes 10 and 11 should not
// appear in the selector.
$this->assertNoOption('edit-book-pid', $nodes[10]->id());
$this->assertNoOption('edit-book-pid', $nodes[11]->id());
$this->assertSession()->optionNotExists('edit-book-pid', $nodes[10]->id());
$this->assertSession()->optionNotExists('edit-book-pid', $nodes[11]->id());
// Node 9 should be available as an option.
$this->assertOption('edit-book-pid', $nodes[9]->id());
$this->assertSession()->optionExists('edit-book-pid', $nodes[9]->id());
// Get a shallow set of options.
/** @var \Drupal\book\BookManagerInterface $manager */
......
......@@ -490,9 +490,9 @@ public function testsNonIntegerIdEntities() {
// Visit the Field UI field add page.
$this->drupalGet('entity_test_string_id/structure/entity_test/fields/add-field');
// Ensure field isn't shown for string IDs.
$this->assertNoOption('edit-new-storage-type', 'comment');
$this->assertSession()->optionNotExists('edit-new-storage-type', 'comment');
// Ensure a core field type shown.
$this->assertOption('edit-new-storage-type', 'boolean');
$this->assertSession()->optionExists('edit-new-storage-type', 'boolean');
// Create a bundle for entity_test_no_id.
entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_no_id');
......@@ -502,9 +502,9 @@ public function testsNonIntegerIdEntities() {
// Visit the Field UI field add page.
$this->drupalGet('entity_test_no_id/structure/entity_test/fields/add-field');
// Ensure field isn't shown for empty IDs.
$this->assertNoOption('edit-new-storage-type', 'comment');
$this->assertSession()->optionNotExists('edit-new-storage-type', 'comment');
// Ensure a core field type shown.
$this->assertOption('edit-new-storage-type', 'boolean');
$this->assertSession()->optionExists('edit-new-storage-type', 'boolean');
}
}
......@@ -86,9 +86,9 @@ public function testLimitExposedOperators() {
$this->drupalGet('test_exposed_filter_datetime');
$this->assertSession()->statusCodeEquals(200);
$this->assertOption('edit-field-date-value-op', '=');
$this->assertNoOption('edit-field-date-value-op', '>');
$this->assertNoOption('edit-field-date-value-op', '>=');
$this->assertSession()->optionExists('edit-field-date-value-op', '=');
$this->assertSession()->optionNotExists('edit-field-date-value-op', '>');
$this->assertSession()->optionNotExists('edit-field-date-value-op', '>=');
// Because there are not operators that use the min and max fields, those
// fields should not be in the exposed form.
......@@ -104,11 +104,11 @@ public function testLimitExposedOperators() {
$this->drupalGet('test_exposed_filter_datetime');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoOption('edit-field-date-value-op', '<');
$this->assertNoOption('edit-field-date-value-op', '<=');
$this->assertNoOption('edit-field-date-value-op', '=');
$this->assertOption('edit-field-date-value-op', '>');
$this->assertOption('edit-field-date-value-op', '>=');
$this->assertSession()->optionNotExists('edit-field-date-value-op', '<');
$this->assertSession()->optionNotExists('edit-field-date-value-op', '<=');
$this->assertSession()->optionNotExists('edit-field-date-value-op', '=');
$this->assertSession()->optionExists('edit-field-date-value-op', '>');
$this->assertSession()->optionExists('edit-field-date-value-op', '>=');
$this->assertFieldById('edit-field-date-value-value');
$this->assertFieldById('edit-field-date-value-min');
......
......@@ -83,8 +83,8 @@ public function testFieldAdminHandler() {
$this->drupalGet($bundle_path . '/fields/add-field');
// Check if the commonly referenced entity types appear in the list.
$this->assertOption('edit-new-storage-type', 'field_ui:entity_reference:node');
$this->assertOption('edit-new-storage-type', 'field_ui:entity_reference:user');
$this->assertSession()->optionExists('edit-new-storage-type', 'field_ui:entity_reference:node');
$this->assertSession()->optionExists('edit-new-storage-type', 'field_ui:entity_reference:user');
$page->findField('new_storage_type')->setValue('entity_reference');
$assert_session->waitForField('label')->setValue('Test');
......
......@@ -752,8 +752,8 @@ public function testPreconfiguredFields() {
// Check that the preconfigured field option exist alongside the regular
// field type option.
$this->assertOption('edit-new-storage-type', 'field_ui:test_field_with_preconfigured_options:custom_options');
$this->assertOption('edit-new-storage-type', 'test_field_with_preconfigured_options');
$this->assertSession()->optionExists('edit-new-storage-type', 'field_ui:test_field_with_preconfigured_options:custom_options');
$this->assertSession()->optionExists('edit-new-storage-type', 'test_field_with_preconfigured_options');
// Add a field with every possible preconfigured value.
$this->fieldUIAddNewField(NULL, 'test_custom_options', 'Test label', 'field_ui:test_field_with_preconfigured_options:custom_options');
......
......@@ -84,7 +84,8 @@ public function testStringTranslation() {
// No t() here, it's surely not translated yet.
$this->assertText($name, 'name found on edit screen.');
$this->assertNoOption('edit-langcode', 'en', 'No way to translate the string to English.');
// Verify that there is no way to translate the string to English.
$this->assertSession()->optionNotExists('edit-langcode', 'en');
$this->drupalLogout();
$this->drupalLogin($admin_user);
$this->drupalPostForm('admin/config/regional/language/edit/en', ['locale_translate_english' => TRUE], t('Save language'));
......
......@@ -248,10 +248,10 @@ public function testMenuNodeFormWidget() {
// Edit the first node.
$this->drupalGet('node/' . $node->id() . '/edit');
// Assert that it is not possible to set the parent of the first node to itself or the second node.
$this->assertNoOption('edit-menu-menu-parent', 'tools:' . $item->getPluginId());
$this->assertNoOption('edit-menu-menu-parent', 'tools:' . $child_item->getPluginId());
$this->assertSession()->optionNotExists('edit-menu-menu-parent', 'tools:' . $item->getPluginId());
$this->assertSession()->optionNotExists('edit-menu-menu-parent', 'tools:' . $child_item->getPluginId());
// Assert that unallowed Administration menu is not available in options.
$this->assertNoOption('edit-menu-menu-parent', 'admin:');
$this->assertSession()->optionNotExists('edit-menu-menu-parent', 'admin:');
}
/**
......
......@@ -674,12 +674,12 @@ public function checkInvalidParentMenuLinks() {
// The last link cannot be a parent in the new menu link form.
$this->drupalGet('admin/structure/menu/manage/admin/add');
$value = 'tools:' . $last_link->getPluginId();
$this->assertNoOption('edit-menu-parent', $value, 'The invalid option is not there.');
$this->assertSession()->optionNotExists('edit-menu-parent', $value);
// All but the last link can be parents in the new menu link form.
array_pop($created_links);
foreach ($created_links as $key => $link) {
$this->assertOption('edit-menu-parent', $link, 'The valid option number ' . ($key + 1) . ' is there.');
$this->assertSession()->optionExists('edit-menu-parent', $link);
}
}
......
......@@ -123,12 +123,12 @@ public function testBulkForm() {
$this->drupalPostForm('admin/structure/views/nojs/handler/test_user_bulk_form/default/field/user_bulk_form', $edit, t('Apply'));
$this->drupalPostForm(NULL, [], t('Save'));
$this->drupalGet('test-user-bulk-form');
$this->assertNoOption('edit-action', $action_id);
$this->assertSession()->optionNotExists('edit-action', $action_id);
$edit['options[include_exclude]'] = 'include';
$this->drupalPostForm('admin/structure/views/nojs/handler/test_user_bulk_form/default/field/user_bulk_form', $edit, t('Apply'));
$this->drupalPostForm(NULL, [], t('Save'));
$this->drupalGet('test-user-bulk-form');
$this->assertOption('edit-action', $action_id);
$this->assertSession()->optionExists('edit-action', $action_id);
}
/**
......
......@@ -114,8 +114,8 @@ public function testBulkForm() {
$this->drupalGet('test_bulk_form');
$options = $this->xpath('//select[@id=:id]/option', [':id' => 'edit-action']);
$this->assertCount(2, $options);
$this->assertOption('edit-action', 'node_make_sticky_action');
$this->assertOption('edit-action', 'node_make_unsticky_action');
$this->assertSession()->optionExists('edit-action', 'node_make_sticky_action');
$this->assertSession()->optionExists('edit-action', 'node_make_unsticky_action');
// Set up to exclude the sticky actions.
$view = Views::getView('test_bulk_form');
......@@ -124,8 +124,8 @@ public function testBulkForm() {
$view->save();
$this->drupalGet('test_bulk_form');
$this->assertNoOption('edit-action', 'node_make_sticky_action');
$this->assertNoOption('edit-action', 'node_make_unsticky_action');
$this->assertSession()->optionNotExists('edit-action', 'node_make_sticky_action');
$this->assertSession()->optionNotExists('edit-action', 'node_make_unsticky_action');
// Check the default title.
$this->drupalGet('test_bulk_form');
......
......@@ -177,11 +177,11 @@ public function testLimitExposedOperators() {
$this->drupalGet('test_filter_in_operator_ui');
$this->assertSession()->statusCodeEquals(200);
$this->assertOption('edit-nid-op', '<');
$this->assertOption('edit-nid-op', '<=');
$this->assertOption('edit-nid-op', '=');
$this->assertNoOption('edit-nid-op', '>');
$this->assertNoOption('edit-nid-op', '>=');
$this->assertSession()->optionExists('edit-nid-op', '<');
$this->assertSession()->optionExists('edit-nid-op', '<=');
$this->assertSession()->optionExists('edit-nid-op', '=');
$this->assertSession()->optionNotExists('edit-nid-op', '>');
$this->assertSession()->optionNotExists('edit-nid-op', '>=');
// Because there are not operators that use the min and max fields, those
// fields should not be in the exposed form.
......@@ -197,11 +197,11 @@ public function testLimitExposedOperators() {
$this->drupalGet('test_filter_in_operator_ui');
$this->assertSession()->statusCodeEquals(200);
$this->assertNoOption('edit-nid-op', '<');
$this->assertNoOption('edit-nid-op', '<=');
$this->assertNoOption('edit-nid-op', '=');
$this->assertOption('edit-nid-op', '>');
$this->assertOption('edit-nid-op', '>=');
$this->assertSession()->optionNotExists('edit-nid-op', '<');
$this->assertSession()->optionNotExists('edit-nid-op', '<=');
$this->assertSession()->optionNotExists('edit-nid-op', '=');
$this->assertSession()->optionExists('edit-nid-op', '>');
$this->assertSession()->optionExists('edit-nid-op', '>=');
$this->assertFieldById('edit-nid-value');
$this->assertFieldById('edit-nid-min');
......
......@@ -458,6 +458,10 @@ public function testFieldAssertsForTextfields() {
/**
* Tests legacy field asserts for options field type.
*
* @group legacy
* @expectedDeprecation AssertLegacyTrait::assertOption() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionExists() instead. See https://www.drupal.org/node/3129738
* @expectedDeprecation AssertLegacyTrait::assertNoOption() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionNotExists() instead. See https://www.drupal.org/node/3129738
*/
public function testFieldAssertsForOptions() {
$this->drupalGet('test-field-xpath');
......
......@@ -27,12 +27,12 @@ protected function setUpLanguage() {
// Check that all predefined languages show up with their native names.
$this->visitInstaller();
foreach (LanguageManager::getStandardLanguageList() as $langcode => $names) {
$this->assertOption('edit-langcode', $langcode);
$this->assertSession()->optionExists('edit-langcode', $langcode);
$this->assertRaw('>' . $names[1] . '<');
}
// Check that our custom one shows up with the file name indicated language.
$this->assertOption('edit-langcode', 'xoxo');
$this->assertSession()->optionExists('edit-langcode', 'xoxo');
$this->assertRaw('>xoxo<');
parent::setUpLanguage();
......
......@@ -194,9 +194,7 @@ public static function getSkippedDeprecations() {
'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::assertOption() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionExists() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertOptionByText() is deprecated in drupal:8.4.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionExists() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertNoOption() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionNotExists() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertOptionSelected() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionExists() instead and check the "selected" attribute. 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',
......
Markdown is supported
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