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

Issue #3139431 by mohrerao, mondrake: Replace usages of...

Issue #3139431 by mohrerao, mondrake: Replace usages of AssertLegacyTrait::assertFieldsByValue, that is deprecated
parent e0c8ce15
No related branches found
No related tags found
7 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,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage"
......@@ -84,7 +84,7 @@ public function testMultiForm() {
$this->assertCount(2, $fields);
foreach ($fields as $field) {
$this->assertCount(1, $field->findAll('xpath', '.' . $field_items_xpath_suffix), 'Found the correct number of field items on the initial page.');
$this->assertFieldsByValue($field->find('xpath', '.' . $button_xpath_suffix), NULL, 'Found the "add more" button on the initial page.');
$this->assertNotNull($field->find('xpath', '.' . $button_xpath_suffix), 'Found the "add more" button on the initial page.');
}
$this->assertSession()->pageContainsNoDuplicateId();
......@@ -106,7 +106,7 @@ public function testMultiForm() {
$page_updated = $session->getPage();
$field = $page_updated->findAll('xpath', '.' . $field_xpath);
$this->assertCount($i + 2, $field[0]->find('xpath', '.' . $field_items_xpath_suffix), 'Found the correct number of field items after an AJAX submission.');
$this->assertFieldsByValue($field[0]->find('xpath', '.' . $button_xpath_suffix), NULL, 'Found the "add more" button after an AJAX submission.');
$this->assertNotNull($field[0]->find('xpath', '.' . $button_xpath_suffix), 'Found the "add more" button after an AJAX submission.');
$this->assertSession()->pageContainsNoDuplicateId();
}
}
......
......@@ -330,18 +330,25 @@ public function testBuildXPathQuery() {
$this->buildXPathQuery('\\html');
}
/**
* Tests legacy assertFieldsByValue().
*
* @group legacy
*/
public function testAssertFieldsByValue() {
$this->expectDeprecation('AssertLegacyTrait::assertFieldsByValue() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use iteration over the fields yourself instead and directly check the values in the test. See https://www.drupal.org/node/3129738');
$this->drupalGet('test-field-xpath');
$this->assertFieldsByValue($this->xpath("//h1[@class = 'page-title']"), NULL);
}
/**
* Tests legacy field asserts which use xpath directly.
*/
public function testXpathAsserts() {
$this->drupalGet('test-field-xpath');
$this->assertFieldsByValue($this->xpath("//h1[@class = 'page-title']"), NULL);
$this->assertFieldsByValue($this->xpath('//table/tbody/tr[2]/td[1]'), 'one');
$this->assertSession()->elementTextContains('xpath', '//table/tbody/tr[2]/td[1]', 'one');
$this->assertFieldsByValue($this->xpath("//input[@id = 'edit-name']"), 'Test name');
$this->assertSession()->fieldValueEquals('edit-name', 'Test name');
$this->assertFieldsByValue($this->xpath("//select[@id = 'edit-options']"), '2');
$this->assertSession()->fieldValueEquals('edit-options', '2');
$this->assertSession()->elementNotExists('xpath', '//notexisting');
......@@ -363,14 +370,6 @@ public function testXpathAsserts() {
catch (ExpectationException $e) {
// Expected exception; just continue testing.
}
try {
$this->assertFieldsByValue($this->xpath("//input[@id = 'edit-name']"), 'not the value');
$this->fail('The "edit-name" field is found with the value "not the value".');
}
catch (ExpectationFailedException $e) {
// Expected exception; just continue testing.
}
}
/**
......@@ -511,7 +510,7 @@ public function testFieldAssertsForTextfields() {
}
// Test that text areas can contain new lines.
$this->assertFieldsByValue($this->xpath("//textarea[@id = 'edit-test-textarea-with-newline']"), "Test text with\nnewline");
$this->assertSession()->fieldValueEquals('edit-test-textarea-with-newline', "Test text with\nnewline");
}
/**
......
......@@ -129,7 +129,6 @@ public static function getSkippedDeprecations() {
'AssertLegacyTrait::assertNoText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertNoRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertFieldsByValue() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use iteration over the fields yourself instead and directly check the values in the test. See https://www.drupal.org/node/3129738',
// PHPUnit 9.
"The \"PHPUnit\TextUI\DefaultResultPrinter\" class is considered internal This class is not covered by the backward compatibility promise for PHPUnit. It may change without further notice. You should not use it from \"Drupal\Tests\Listeners\HtmlOutputPrinter\".",
'assertFileNotExists() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertFileDoesNotExist() instead.',
......
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