Change record status: 
Project: 
Introduced in branch: 
9.1.x
Introduced in version: 
9.1.0
Description: 

The following test assertion methods, originally inherited in Drupal 8 from Simpletest, have been replaced by PHPUnit methods along the Drupal 8 lifecycle, and are now formally deprecated for removal in Drupal 10.

Developers are advised to convert their tests to replace usages of these methods to their recommended alternatives.

Deprecated method Replacement
assert() $this->assertTrue()
assertEqual() $this->assertEquals()
assertNotEqual() $this->assertNotEquals()
assertIdentical() $this->assertSame()
assertNotIdentical() $this->assertNotSame()
assertIdenticalObject() $this->assertEquals()
pass() n/a - drop the call and/or refactor the test. PHPUnit fails a test as soon as an assertion fails.
assertElementPresent() $this->assertSession()->elementExists()
assertElementNotPresent() $this->assertSession()->elementNotExists()
assertText() $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains()
assertNoText() $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains()
assertUniqueText() $this->getSession()->pageTextContainsOnce() or $this->getSession()->pageTextMatchesCount()
assertNoUniqueText() $this->getSession()->pageTextMatchesCount() if you know the cardinality in advance, or $this->getSession()->getPage()->getText() and substr_count()
assertResponse() $this->assertSession()->statusCodeEquals()
assertFieldByName() $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals()
assertNoFieldByName() $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() or $this->assertSession()->fieldValueNotEquals()
assertFieldById() $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals()
assertField() $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists()
assertNoField() $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists()
assertRaw() $this->assertSession()->responseContains()
assertNoRaw() $this->assertSession()->responseNotContains()
assertTitle() $this->assertSession()->titleEquals()
assertLink() $this->assertSession()->linkExists()
assertNoLink() $this->assertSession()->linkNotExists()
assertLinkByHref() $this->assertSession()->linkByHrefExists()
assertNoLinkByHref() $this->assertSession()->linkByHrefNotExists()
assertNoFieldById() $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() or $this->assertSession()->fieldValueNotEquals()
assertUrl() $this->assertSession()->addressEquals()
assertOption() $this->assertSession()->optionExists()
assertOptionByText() $this->assertSession()->optionExists()
assertNoOption() $this->assertSession()->optionNotExists()
assertOptionSelected() $this->assertSession()->optionExists() instead and check the "selected" attribute
assertFieldChecked() $this->assertSession()->checkboxChecked()
assertNoFieldChecked() $this->assertSession()->checkboxNotChecked()
assertFieldByXPath() $this->xpath() instead and check the values directly in the test
assertNoFieldByXPath() $this->xpath() instead and assert that the result is empty
assertFieldsByValue() Iterate over the fields yourself instead and directly check the values in the test
assertEscaped() $this->assertSession()->assertEscaped()
assertNoEscaped() $this->assertSession()->assertNoEscaped()
assertPattern() $this->assertSession()->responseMatches()
assertNoPattern() $this->assertSession()->responseNotMatches()
assertCacheTag() $this->assertSession()->responseHeaderContains()
assertNoCacheTag() $this->assertSession()->responseHeaderNotContains()
assertHeader() $this->assertSession()->responseHeaderEquals()
buildXPathQuery() $this->assertSession()->buildXPathQuery()
constructFieldXpath() $this->getSession()->getPage()->findField()
getRawContent() $this->getSession()->getPage()->getContent()
getAllOptions() $element->findAll('xpath', 'option')
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

ressa’s picture

Thanks for posting this CR @mondrake. Should this line be removed?
assertText() | $this->assertSession()->pageTextContains() or $this->assertSession()->pageTextNotContains()

mondrake’s picture

Yes! Done, thanks.

ressa’s picture

Cool, thanks!