Problem/Motivation

AssertLegacyTrait:: assertFieldByName and :assertNoFieldByName is deprecated and will be removed in Drupal 10.

There is a total of 17 occurrences which needs to be reviewed and replaced.

Steps to reproduce

Proposed resolution

These will need to be replaced by one of the following assertion methods:

$this->assertSession()->fieldExists()
$this->assertSession()->fieldNotExists()
$this->assertSession()->fieldValueEquals()
$this->assertSession()->fieldValueNotEquals()

Examples:

Before (fieldValue(Not)Equals):

$this->assertFieldByName('title|0|value[translation][value]', $text . 'translated');
$this->assertNoFieldByName('body|deep_nesting[translation][value]', $text . 'no save');

After:

$this->assertSession()->fieldValueEquals('title|0|value[translation][value]', $text . 'translated');
$this->assertSession()->fieldValueNotEquals('body|deep_nesting[translation][value]', $text . 'no save');

Before (field(Not)Exists):

$this->assertFieldByName('embedded_fields[node][entity_test_t_composite]');
$this->assertNoFieldByName('job_type');

After:

$this->assertSession()->fieldExists('embedded_fields[node][entity_test_t_composite]');
$this->assertSession()->fieldNotExists('job_type');

Remaining tasks

User interface changes

API changes

Data model changes

Comments

marcusml created an issue. See original summary.

larisse’s picture

Status: Active » Needs review
StatusFileSize
new8.66 KB

Hi! Here's a patch to fix this.

In the files ContentEntitySourceTranslatableEntityTest.php and TMGMTUiReviewTest.php, the assertFieldByName needs 2 parameters and I don't sure if I can put 'NULL' or ' ', so I just don't fixed this.
The same occur to ContentEntitySourceTranslatableEntityTest.php and TMGMTUiReviewTest.php for assertFieldByName function.

marcusml’s picture

StatusFileSize
new10.4 KB
new1.74 KB

Thanks again larisse! The occurrences in ContentEntitySourceTranslatableEntityTest.php and TMGMTUiReviewTest.php needed to be replaced with $this->assertSession()->fieldExists().

Here's a patch which includes the missing two.

berdir’s picture

Status: Needs review » Needs work

This needs a reroll as well.

marcusml’s picture

Status: Needs work » Needs review
StatusFileSize
new10.45 KB

Rerolled.

berdir’s picture

Status: Needs review » Fixed

Committed.

  • Berdir committed c413c02 on 8.x-1.x authored by marcusml
    Issue #3273368 by marcusml, larisse: assertFieldByName and...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.