Skip to content
Snippets Groups Projects
Commit 172e4b5a authored by catch's avatar catch
Browse files

Issue #3189607 by Spokje, longwave, Pooja Ganjage, anmolgoyal74: Convert...

Issue #3189607 by Spokje, longwave, Pooja Ganjage, anmolgoyal74: Convert assertions involving use of xpath on checkboxes to WebAssert
parent 3ac9df13
No related branches found
No related tags found
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!16Draft: Resolve #2081585 "History storage"
......@@ -200,8 +200,7 @@ public function testExistingFormat() {
$this->resetAll();
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and not(@checked)]');
$this->assertCount(1, $ultra_llama_mode_checkbox, 'The "Ultra llama mode" checkbox exists and is not checked.');
$this->assertSession()->checkboxNotChecked('editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]');
$editor = Editor::load('filtered_html');
$this->assertInstanceOf(Editor::class, $editor);
$this->assertEqual($expected_settings, $editor->getSettings(), 'The Editor config entity has the correct settings.');
......@@ -213,8 +212,7 @@ public function testExistingFormat() {
];
$this->submitForm($edit, 'Save configuration');
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
$ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]');
$this->assertCount(1, $ultra_llama_mode_checkbox, 'The "Ultra llama mode" checkbox exists and is checked.');
$this->assertSession()->checkboxChecked('editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]');
$expected_settings['plugins']['llama_contextual_and_button']['ultra_llama_mode'] = TRUE;
$editor = Editor::load('filtered_html');
$this->assertInstanceOf(Editor::class, $editor);
......
......@@ -92,8 +92,7 @@ public function testAddEditorToExistingFormat() {
'editor[editor]' => '',
];
$this->submitForm($edit, 'Configure');
$unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
$this->assertCount(0, $unicorn_setting, "Unicorn Editor's settings form is no longer present.");
$this->assertSession()->fieldNotExists('editor[settings][ponies_too]');
}
/**
......@@ -224,8 +223,7 @@ protected function selectUnicornEditor() {
'editor[editor]' => 'unicorn',
];
$this->submitForm($edit, 'Configure');
$unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]');
$this->assertCount(1, $unicorn_setting, "Unicorn Editor's settings form is present.");
$this->assertSession()->checkboxChecked('editor[settings][ponies_too]');
return $edit;
}
......
......@@ -64,8 +64,7 @@ public function testMissingModules() {
// as missing a dependency.
$this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst('_missing_dependency')]));
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_dependencies_test][enable]"]');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
$this->assertSession()->checkboxNotChecked('modules[system_dependencies_test][enable]');
}
/**
......@@ -79,8 +78,7 @@ public function testIncompatibleModuleVersionDependency() {
'@module' => 'System incompatible module version test (>2.0)',
'@version' => '1.0',
]));
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_module_version_dependencies_test][enable]"]');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
$this->assertSession()->fieldDisabled('modules[system_incompatible_module_version_dependencies_test][enable]');
}
/**
......@@ -93,8 +91,7 @@ public function testIncompatibleCoreVersionDependency() {
$this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
'@module' => 'System core incompatible semver test',
]));
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_core_version_dependencies_test][enable]"]');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
$this->assertSession()->fieldDisabled('modules[system_incompatible_core_version_dependencies_test][enable]');
}
/**
......@@ -103,8 +100,7 @@ public function testIncompatibleCoreVersionDependency() {
public function testIncompatiblePhpVersionDependency() {
$this->drupalGet('admin/modules');
$this->assertRaw('This module requires PHP version 6502.* and is incompatible with PHP version ' . phpversion() . '.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_php_version_test][enable]"]');
$this->assertCount(1, $checkbox, 'Checkbox for the module is disabled.');
$this->assertSession()->fieldDisabled('modules[system_incompatible_php_version_test][enable]');
}
/**
......@@ -201,8 +197,7 @@ public function testUninstallDependents() {
// Check that the comment module cannot be uninstalled.
$this->drupalGet('admin/modules/uninstall');
$checkbox = $this->xpath('//input[@type="checkbox" and @name="uninstall[comment]" and @disabled="disabled"]');
$this->assertCount(1, $checkbox, 'Checkbox for uninstalling the comment module is disabled.');
$this->assertSession()->fieldDisabled('uninstall[comment]');
// Delete any forum terms.
$vid = $this->config('forum.settings')->get('vocabulary');
......
......@@ -174,11 +174,8 @@ public function testInstallUninstall() {
// See if we can currently uninstall this module (if its dependencies
// have been uninstalled), and do so if we can.
$this->drupalGet('admin/modules/uninstall');
$field_name = "uninstall[$to_uninstall]";
$has_checkbox = $this->xpath('//input[@type="checkbox" and @name="' . $field_name . '"]');
$disabled = $this->xpath('//input[@type="checkbox" and @name="' . $field_name . '" and @disabled="disabled"]');
if (!empty($has_checkbox) && empty($disabled)) {
$checkbox = $this->assertSession()->fieldExists("uninstall[$to_uninstall]");
if (!$checkbox->hasAttribute('disabled')) {
// This one is eligible for being uninstalled.
$package = $all_modules[$to_uninstall]->info['package'];
$this->assertSuccessfulUninstall($to_uninstall, $package);
......
......@@ -53,8 +53,12 @@ public function testModuleVersions() {
$n = count($dependencies);
for ($i = 0; $i < $n; $i++) {
$this->drupalGet('admin/modules');
$checkbox = $this->xpath('//input[@id="edit-modules-module-test-enable"]');
$this->assertEqual($i % 2, !empty($checkbox[0]->getAttribute('disabled')), $dependencies[$i]);
if ($i % 2 == 0) {
$this->assertSession()->fieldEnabled('edit-modules-module-test-enable');
}
else {
$this->assertSession()->fieldDisabled('edit-modules-module-test-enable');
}
}
}
......
......@@ -97,10 +97,8 @@ public function testExposedFormRenderCheckboxes() {
$view->save();
$this->drupalGet('test_exposed_form_checkboxes');
$actual = $this->xpath('//form//input[@type="checkbox" and @name="type[article]"]');
$this->assertCount(1, $actual, 'Article option renders as a checkbox.');
$actual = $this->xpath('//form//input[@type="checkbox" and @name="type[page]"]');
$this->assertCount(1, $actual, 'Page option renders as a checkbox');
$this->assertSame('checkbox', $this->assertSession()->fieldExists('type[article]')->getAttribute('type'));
$this->assertSame('checkbox', $this->assertSession()->fieldExists('type[page]')->getAttribute('type'));
// Ensure that all results are displayed.
$rows = $this->xpath("//div[contains(@class, 'views-row')]");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment