Problem/Motivation

AssertLegacyTrait::assertFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals() instead. See https://www.drupal.org/node/3129738

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#77 interdiff_3139407_73-77.txt788 bytesankithashetty
#77 3139407-77.patch51.16 KBankithashetty
#73 3139407-73.patch51.15 KBpaulocs
#73 diff.txt1.93 KBpaulocs
#69 interdiff_67_69.txt1.07 KBanmolgoyal74
#69 3139407-69.patch51.15 KBanmolgoyal74
#67 3139407-66.patch51.1 KBshetpooja04
#66 interdiff_63-66.txt3.29 KBshetpooja04
#66 3139407-66.patch51.39 KBshetpooja04
#63 interdiff_60-63.txt9.76 KBravi.shankar
#63 3139407-63.patch51.81 KBravi.shankar
#60 interdiff_58-60.txt4.85 KBmondrake
#60 3139408-60.patch52.36 KBmondrake
#58 rawdiff_55-58.txt9.57 KBmondrake
#58 3139407-58.patch50.29 KBmondrake
#55 interdiff_54-55.txt2.23 KBmohrerao
#55 3139407-55.patch50.41 KBmohrerao
#54 interdiff_52-54.txt3.55 KBmohrerao
#54 3139407-54.patch49.43 KBmohrerao
#52 interdiff_49-52.txt14.94 KBdurgeshs
#52 3139407-52.patch45.74 KBdurgeshs
#49 interdiff_46-49.txt5.62 KBdurgeshs
#49 3139407-49.patch38 KBdurgeshs
#46 interdiff_40-46.txt1.34 KBrahulrasgon
#46 3139407-46.patch43.89 KBrahulrasgon
#43 3139407-43.patch38 KBshaktik
#40 interdiff-36-40.txt9.4 KBrahulrasgon
#40 3139407-40.patch43.88 KBrahulrasgon
#38 patch-apply-fail-report.txt3.43 KBshaktik
#36 3139407-36.patch41.69 KBHardik_Patel_12
#35 interdiff_33-35.txt4.12 KBmohrerao
#35 3139407-35.patch38.07 KBmohrerao
#33 interdiff_27-33.txt24.27 KBmohrerao
#33 3139407-33.patch38.2 KBmohrerao
#32 interdiff_27-32.txt24.27 KBmohrerao
#32 3139407-32.patch38.2 KBmohrerao
#27 interdiff_22-27.txt2 KBshaktik
#27 3139407-27.patch45.18 KBshaktik
#22 3139407-22.patch45.04 KBpavnish
#19 interdiff_15-19.txt7.86 KBpavnish
#19 3139407-19.patch45.04 KBpavnish
#15 interdiff_5-15.txt28.83 KBpavnish
#15 3139407-15.patch36.3 KBpavnish
#13 3139407-12.patch36.31 KBpavnish
#11 3139407-10.patch37.15 KBpavnish
#9 3139407-8.patch37.18 KBpavnish
#8 3139407-8.patch37.17 KBpavnish
#5 3139407-5.patch37.4 KBmunish.kumar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

mondrake’s picture

Title: Replace usages of AssertLegacyTrait::assertFieldById, that is deprecated » Replace usages of AssertLegacyTrait::assert(No)FieldById, that is deprecated
jungle’s picture

Issue tags: +Deprecated assertions

Adding the "Deprecated assertions" tag to add this into the kanban board https://contribkanban.com/board/Deprecatedassertions

munish.kumar’s picture

Assigned: Unassigned » munish.kumar
munish.kumar’s picture

Assigned: munish.kumar » Unassigned
Status: Active » Needs review
FileSize
37.4 KB

Status: Needs review » Needs work

The last submitted patch, 5: 3139407-5.patch, failed testing. View results

pavnish’s picture

Assigned: Unassigned » pavnish
pavnish’s picture

Status: Needs work » Needs review
FileSize
37.17 KB
pavnish’s picture

Status: Needs review » Needs work

The last submitted patch, 9: 3139407-8.patch, failed testing. View results

pavnish’s picture

Status: Needs work » Needs review
FileSize
37.15 KB

Status: Needs review » Needs work

The last submitted patch, 11: 3139407-10.patch, failed testing. View results

pavnish’s picture

Status: Needs work » Needs review
FileSize
36.31 KB

Status: Needs review » Needs work

The last submitted patch, 13: 3139407-12.patch, failed testing. View results

pavnish’s picture

Assigned: pavnish » Unassigned
Status: Needs work » Needs review
FileSize
36.3 KB
28.83 KB

HI please review this patch.
Fix failed test cases.

pavnish’s picture

daffie’s picture

Status: Needs review » Needs work

When I do a code base search for $this->assertFieldById( and $this->assertNoFieldById( I still get results. More code changes are needed.

pavnish’s picture

Assigned: Unassigned » pavnish
pavnish’s picture

Assigned: pavnish » Unassigned
Status: Needs work » Needs review
FileSize
45.04 KB
7.86 KB

@daffie Thanks

RE #17 has been done can you please review this patch.

Status: Needs review » Needs work

The last submitted patch, 19: 3139407-19.patch, failed testing. View results

pavnish’s picture

Assigned: Unassigned » pavnish
pavnish’s picture

Assigned: pavnish » Unassigned
Status: Needs work » Needs review
FileSize
45.04 KB

Status: Needs review » Needs work

The last submitted patch, 22: 3139407-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

pavnish’s picture

Assigned: Unassigned » pavnish

Working on failed tests

pavnish’s picture

Assigned: pavnish » Unassigned

Need to update test case.

shaktik’s picture

Assigned: Unassigned » shaktik
shaktik’s picture

shaktik’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 27: 3139407-27.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

shaktik’s picture

Assigned: shaktik » Unassigned
pavnish’s picture

Assigned: Unassigned » pavnish
mohrerao’s picture

Did a quick review and found major issues on previous patches.

  1. Replaced assertSession()->field(Not)Exists to assertSession()->fieldValue(Not)Equals as there is actually verification of field values.
  2. Replaced assertSession()->field(Not)Exists to assertSession()->button(Not)Exists where button is verified.
  3. Replaced Replaced assertSession()->field(Not)Exists to Replaced assertSession()->checkbox(Not)Checked for checkboxes
  4. Removed all assert(No)FieldById in Legacy methods
mohrerao’s picture

Status: Needs work » Needs review
FileSize
38.2 KB
24.27 KB

Fixed PHP lint failure.

Status: Needs review » Needs work

The last submitted patch, 33: 3139407-33.patch, failed testing. View results

mohrerao’s picture

Status: Needs work » Needs review
FileSize
38.07 KB
4.12 KB

Fixed Failing tests.

Hardik_Patel_12’s picture

Patch failed to apply , kindly follow a new patch.

Status: Needs review » Needs work

The last submitted patch, 36: 3139407-36.patch, failed testing. View results

shaktik’s picture

FileSize
3.43 KB

Hi @Hardik_Patel_12,

Could you please add interdiff its drupal ci say the patch is pass and I am also not able to apply the #35 attached file failer report.

Thanks,
Shakti.

rahulrasgon’s picture

Assigned: pavnish » rahulrasgon
rahulrasgon’s picture

Assigned: rahulrasgon » Unassigned
Status: Needs work » Needs review
FileSize
43.88 KB
9.4 KB

Please review the following patch.

Thanks

Status: Needs review » Needs work

The last submitted patch, 40: 3139407-40.patch, failed testing. View results

hash6’s picture

Assigned: Unassigned » hash6
shaktik’s picture

Status: Needs work » Needs review
FileSize
38 KB

Hi @hash6,

Just reroll patch from #35

rahulrasgon’s picture

Status: Needs review » Needs work

@shaktik after applying #43 when I do a code base search for $this->assertFieldById( and $this->assertNoFieldById( I still get results. More code changes are needed.

File: core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php still get results with $this->assertFieldById( and $this->assertNoFieldById( .

rahulrasgon’s picture

Assigned: hash6 » rahulrasgon

Working on failed test cases on #40.

rahulrasgon’s picture

Assigned: rahulrasgon » Unassigned
Status: Needs work » Needs review
FileSize
43.89 KB
1.34 KB

Please review the patch.
Thanks

Status: Needs review » Needs work

The last submitted patch, 46: 3139407-46.patch, failed testing. View results

durgeshs’s picture

Assigned: Unassigned » durgeshs
durgeshs’s picture

Assigned: durgeshs » Unassigned
Status: Needs work » Needs review
FileSize
38 KB
5.62 KB

Please review this patch.
Thanks,

mondrake’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Need a deprecation test for the deprecated methods, and the deprecation silencers removed from the DeprecationListenerTrait.

All these seem to be checking for the field value too. not just for the field existence:

+++ b/core/modules/block/tests/src/Functional/Views/DisplayBlockTest.php
@@ -206,7 +206,7 @@ public function testViewsBlockForm() {
-    $this->assertNoFieldById('edit-machine-name', 'views_block__test_view_block_1', 'The machine name is hidden on the views block form.');
+    $this->assertSession()->fieldNotExists('edit-machine-name', NULL, 'The machine name is hidden on the views block form.');

+++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
@@ -231,12 +231,12 @@ public function testEditComment() {
-    $this->assertNoFieldById('edit-mail', $comment->getAuthorEmail());
+    $this->assertSession()->fieldNotExists('edit-mail', NULL, $comment->getAuthorEmail());
...
-    $this->assertFieldById('edit-mail', $anonymous_comment->getAuthorEmail());
+    $this->assertSession()->fieldExists('edit-mail', NULL, $anonymous_comment->getAuthorEmail());

+++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
@@ -458,7 +458,7 @@ public function testDefaultValue() {
-    $this->assertFieldById($element_id, '', 'The default value widget was empty.');
+    $this->assertSession()->fieldExists($element_id, NULL, 'The default value widget was empty.');

@@ -474,7 +474,7 @@ public function testDefaultValue() {
-    $this->assertFieldById($element_id, '1', 'The default value widget was displayed with the correct value.');
+    $this->assertSession()->fieldExists($element_id, NULL, 'The default value widget was displayed with the correct value.');

@@ -506,7 +506,7 @@ public function testDefaultValue() {
-    $this->assertFieldById($element_id, '', 'The default value widget was displayed when field is hidden.');
+    $this->assertSession()->fieldExists($element_id, NULL, 'The default value widget was displayed when field is hidden.');

+++ b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php
@@ -205,7 +205,7 @@ public function testConfigTranslation() {
-    $this->assertFieldById('edit-label', 'Website feedback', 'Translation is not loaded for Edit Form.');
+    $this->assertSession()->fieldValueEquals('edit-label', 'Website feedback');

+++ b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
@@ -177,8 +177,8 @@ protected function runRevisionsTests($entity_type) {
-    $this->assertFieldById('edit-name-0-value', $entity->name->value, new FormattableMarkup('%entity_type: Name matches in UI.', ['%entity_type' => $entity_type]));
-    $this->assertFieldById('edit-translatable-test-field-0-value', $entity->translatable_test_field->value, new FormattableMarkup('%entity_type: Text matches in UI.', ['%entity_type' => $entity_type]));
+    $this->assertSession()->fieldExists('edit-name-0-value', NULL);
+    $this->assertSession()->fieldExists('edit-translatable-test-field-0-value', NULL);

+++ b/core/modules/user/tests/src/Functional/UserCreateTest.php
@@ -76,8 +76,8 @@ public function testUserAdd() {
-    $this->assertFieldbyId('edit-status-0', 0, 'The user status option Blocked exists.', 'User login');
-    $this->assertFieldbyId('edit-status-1', 1, 'The user status option Active exists.', 'User login');
+    $this->assertSession()->fieldExists('edit-status-0');
+    $this->assertSession()->fieldExists('edit-status-1');

+++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
@@ -115,7 +115,7 @@ public function testExposedIdentifier() {
-    $this->assertFieldById(Html::getId('edit-' . $identifier), 'article', "Article type filter set with new identifier.");
+    $this->assertSession()->fieldExists(Html::getId('edit-' . $identifier), NULL);

+++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php
@@ -73,10 +73,10 @@ public function testExposedAdminUi() {
-    $this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists');
-    $this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists');
...
+    $this->assertSession()->fieldExists('edit-options-operator-in');
+    $this->assertSession()->fieldExists('edit-options-operator-not-in');

@@ -84,10 +84,10 @@ public function testExposedAdminUi() {
-    $this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists');
-    $this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists');
...
+    $this->assertSession()->fieldExists('edit-options-operator-in');
+    $this->assertSession()->fieldExists('edit-options-operator-not-in');

@@ -103,24 +103,24 @@ public function testExposedAdminUi() {
-    $this->assertNoFieldById('edit-options-expose-label', '', 'Make sure no label field is shown');
+    $this->assertSession()->fieldNotExists('edit-options-expose-label', NULL);
...
-    $this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists after hide filter');
-    $this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists after hide filter');
...
+    $this->assertSession()->fieldExists('edit-options-operator-in');
+    $this->assertSession()->fieldExists('edit-options-operator-not-in');

@@ -162,10 +162,10 @@ public function testGroupedFilterAdminUi() {
-    $this->assertNoFieldById('edit-options-operator-in', 'in', 'Operator In not exists');
-    $this->assertNoFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In not exists');
-    $this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists');
-    $this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists');
+    $this->assertSession()->fieldNotExists('edit-options-operator-in');
+    $this->assertSession()->fieldNotExists('edit-options-operator-not-in');
+    $this->assertSession()->fieldNotExists('edit-options-value-page');
+    $this->assertSession()->fieldNotExists('edit-options-value-article');
durgeshs’s picture

Assigned: Unassigned » durgeshs
durgeshs’s picture

Assigned: durgeshs » Unassigned
Status: Needs work » Needs review
FileSize
45.74 KB
14.94 KB

Hi @mondrake

I have made changes as per #50, kindly review it.

jungle’s picture

Status: Needs review » Needs work

Need a deprecation test for the deprecated methods, and the deprecation silencers removed from the DeprecationListenerTrait.

#50 hasn't been fully addressed.

mohrerao’s picture

Removing deprecation silencers removed from the DeprecationListenerTrait.

mohrerao’s picture

Status: Needs work » Needs review
FileSize
50.41 KB
2.23 KB

The failure is in testFieldAssertsForButton from core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php.
Updated testFieldAssertsForButton method from core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php with new assertions.

jungle’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Thanks @mohrerao!

Need a deprecation test for the deprecated methods, and the deprecation silencers removed from the DeprecationListenerTrait.

  1. "Need a deprecation test for the deprecated methods" has not been addressed yet, still. ❌
  2. "and the deprecation silencers removed from the DeprecationListenerTrait." ✅
  3. Needs reroll
jungle’s picture

Status: Needs work » Postponed

Postpone on #3139406: Replace usages of AssertLegacyTrait::assert(No)FieldByName, that is deprecated, Some usages in BrowserTestBase could be removed due to the replacement is the same, and overlapped.

Status: Needs review » Needs work

The last submitted patch, 58: 3139407-58.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mondrake’s picture

Status: Needs work » Needs review
FileSize
52.36 KB
4.85 KB

Fixes.

longwave’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
    @@ -231,12 +231,13 @@ public function testEditComment() {
    -    $this->assertFieldById('edit-mail', $anonymous_comment->getAuthorEmail());
    +    $this->assertSession()->fieldExists('edit-mail');
    +    $this->assertSession()->fieldValueEquals('edit-mail', $anonymous_comment->getAuthorEmail());
    

    fieldValueEquals() will throw an exception anyway if the field doesn't exist.

  2. +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
    @@ -458,7 +458,8 @@ public function testDefaultValue() {
    -    $this->assertFieldById($element_id, '', 'The default value widget was empty.');
    +    $this->assertSession()->fieldExists($element_id);
    +    $this->assertSession()->fieldValueEquals($element_id, '');
    

    Same

  3. +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
    @@ -474,7 +475,8 @@ public function testDefaultValue() {
    -    $this->assertFieldById($element_id, '1', 'The default value widget was displayed with the correct value.');
    +    $this->assertSession()->fieldExists($element_id);
    +    $this->assertSession()->fieldValueEquals($element_id, '1');
    

    Same

  4. +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
    @@ -506,7 +508,8 @@ public function testDefaultValue() {
    -    $this->assertFieldById($element_id, '', 'The default value widget was displayed when field is hidden.');
    +    $this->assertSession()->fieldExists($element_id);
    +    $this->assertSession()->fieldValueEquals($element_id, '');
    

    Same

  5. +++ b/core/modules/locale/tests/src/Functional/LocaleConfigTranslationTest.php
    @@ -205,7 +205,8 @@ public function testConfigTranslation() {
    +    $this->assertSession()->fieldExists('edit-label');
    +    $this->assertSession()->fieldValueEquals('edit-label', 'Website feedback');
    

    Same

  6. +++ b/core/modules/system/tests/src/Functional/Entity/EntityRevisionsTest.php
    @@ -177,8 +177,10 @@ protected function runRevisionsTests($entity_type) {
    +    $this->assertSession()->fieldExists('edit-name-0-value', NULL);
    +    $this->assertSession()->fieldValueEquals('edit-name-0-value', $entity->name->value);
    +    $this->assertSession()->fieldExists('edit-translatable-test-field-0-value', NULL);
    +    $this->assertSession()->fieldValueEquals('edit-translatable-test-field-0-value', $entity->translatable_test_field->value);
    

    Same

  7. +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
    @@ -121,7 +121,7 @@ public function testFilterUI() {
    -    $this->assertFieldById('edit-options-value', NULL);
    +    $this->assertSession()->fieldExists('edit-options-value', NULL);
    

    We don't need the second argument to fieldExists() here.

  8. +++ b/core/modules/user/tests/src/Functional/UserCreateTest.php
    @@ -76,8 +76,10 @@ public function testUserAdd() {
    +    $this->assertSession()->fieldExists('edit-status-0');
    +    $this->assertSession()->fieldValueEquals('edit-status-0', '1');
    +    $this->assertSession()->fieldExists('edit-status-1');
    +    $this->assertSession()->fieldValueEquals('edit-status-1', '1');
    

    We don't need to check existence separately.

  9. +++ b/core/modules/views/tests/src/Functional/BulkFormTest.php
    @@ -56,12 +56,12 @@ public function testBulkForm() {
    -    $this->assertFieldById('edit-action', NULL, 'The action select field appears.');
    +    $this->assertSession()->fieldExists('edit-action', NULL);
    

    We don't need the second argument.

  10. +++ b/core/modules/views/tests/src/Functional/BulkFormTest.php
    @@ -56,12 +56,12 @@ public function testBulkForm() {
    -      $this->assertFieldById('edit-node-bulk-form-' . $i, NULL, new FormattableMarkup('The checkbox on row @row appears.', ['@row' => $i]));
    +      $this->assertSession()->fieldExists('edit-node-bulk-form-' . $i, NULL);
    

    Same

  11. +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
    @@ -115,7 +115,8 @@ public function testExposedIdentifier() {
    +    $this->assertSession()->fieldExists(Html::getId('edit-' . $identifier), NULL);
    +    $this->assertSession()->fieldValueEquals(Html::getId('edit-' . $identifier), 'article');
    

    We don't need to check existence separately.

  12. +++ b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php
    @@ -185,9 +185,9 @@ public function testLimitExposedOperators() {
    -    $this->assertFieldById('edit-nid-value');
    ...
    +    $this->assertSession()->fieldExists('edit-nid-value');
    

    The default value of '' passed to assertFieldById() also checks the value is an empty string, not just existence.

  13. +++ b/core/modules/views/tests/src/Functional/Plugin/FilterTest.php
    @@ -203,9 +203,9 @@ public function testLimitExposedOperators() {
    -    $this->assertFieldById('edit-nid-value');
    -    $this->assertFieldById('edit-nid-min');
    -    $this->assertFieldById('edit-nid-max');
    +    $this->assertSession()->fieldExists('edit-nid-value');
    +    $this->assertSession()->fieldExists('edit-nid-min');
    +    $this->assertSession()->fieldExists('edit-nid-max');
    

    Same

  14. +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php
    @@ -73,10 +73,12 @@ public function testExposedAdminUi() {
    +    $this->assertSession()->fieldExists('edit-options-operator-in');
    +    $this->assertSession()->fieldValueEquals('edit-options-operator-in', 'in');
    +    $this->assertSession()->fieldExists('edit-options-operator-not-in');
    +    $this->assertSession()->fieldValueEquals('edit-options-operator-not-in', 'in');
    

    We don't need to check for existence separately.

  15. +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php
    @@ -84,10 +86,12 @@ public function testExposedAdminUi() {
    +    $this->assertSession()->fieldExists('edit-options-operator-in');
    +    $this->assertSession()->fieldValueEquals('edit-options-operator-in', 'in');
    +    $this->assertSession()->fieldExists('edit-options-operator-not-in');
    +    $this->assertSession()->fieldValueEquals('edit-options-operator-not-in', 'in');
    

    Same

  16. +++ b/core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php
    @@ -103,24 +107,26 @@ public function testExposedAdminUi() {
    -    $this->assertNoFieldById('edit-options-expose-label', '', 'Make sure no label field is shown');
    +    $this->assertSession()->fieldNotExists('edit-options-expose-label', NULL);
    

    The second argument is unnecessary.

  17. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -425,14 +438,13 @@ public function testFieldAssertsForTextfields() {
    -    $this->assertNoFieldById('name');
    -    $this->assertNoFieldById('name', 'not the value');
    -    $this->assertNoFieldById('notexisting');
    -    $this->assertNoFieldById('notexisting', NULL);
    +    $this->assertSession()->fieldNotExists('name[0][value]', NULL);
    +    $this->assertSession()->fieldValueNotEquals('name', 'not the value');
    +    $this->assertSession()->fieldNotExists('notexisting');
    

    Where did 'name[0][value]' come from?

  18. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -441,7 +453,7 @@ public function testFieldAssertsForTextfields() {
    -      $this->assertNoFieldById('edit-name', NULL);
    +      $this->assertSession()->fieldValueEquals('name', '');
    

    Shouldn't this be fieldNotExists()?

  19. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -449,15 +461,14 @@ public function testFieldAssertsForTextfields() {
    +    $this->assertSession()->fieldExists('edit-name', NULL);
    +    $this->assertSession()->fieldValueEquals('edit-name', 'Test name');
    +    $this->assertSession()->fieldExists('edit-description', NULL);
    +    $this->assertSession()->fieldValueEquals('edit-description', '');
    

    We don't need a second argument to fieldExists()

  20. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -590,32 +600,23 @@ public function testFieldAssertsForOptions() {
    +    // Verify if the test passes with button ID.
    +    $this->assertSession()->buttonExists('edit-save', NULL);
    +    // Verify if the test passes with button Value.
    +    $this->assertSession()->buttonExists('Save', NULL);
    +    // Verify if the test passes with button Name.
    +    $this->assertSession()->buttonExists('op', NULL);
    

    We don't need a second argument to buttonExists()

  21. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -590,32 +600,23 @@ public function testFieldAssertsForOptions() {
    +    // Verify if the test passes with button ID.
    +    $this->assertSession()->buttonNotExists('i-dont-exist', NULL);
    +    // Verify if the test passes with button Value.
    +    $this->assertSession()->buttonNotExists('I dont exist', NULL);
    +    // Verify if the test passes with button Name.
    +    $this->assertSession()->buttonNotExists('no', NULL);
    

    Same

  22. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -590,32 +600,23 @@ public function testFieldAssertsForOptions() {
    -    $this->assertFieldByName('duplicate_button', 'Duplicate button 1');
    -    $this->assertFieldByName('duplicate_button', 'Duplicate button 2');
    -    $this->assertNoFieldByName('duplicate_button', 'Rabbit');
    +    $this->assertSession()->buttonExists('Duplicate button 1');
    +    $this->assertSession()->buttonExists('Duplicate button 2');
    

    Missing the third assertion here

  23. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -678,27 +679,27 @@ public function testFieldAssertsForCheckbox() {
    -    $this->assertFieldById('edit-checkbox-enabled', NULL);
    -    $this->assertFieldById('edit-checkbox-disabled', NULL);
    +    $this->assertSession()->fieldExists('edit-checkbox-enabled', NULL);
    +    $this->assertSession()->fieldExists('edit-checkbox-disabled', NULL);
    

    We don't need the second argument again

  24. +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
    @@ -678,27 +679,27 @@ public function testFieldAssertsForCheckbox() {
    -      $this->assertNoFieldById('edit-checkbox-disabled', NULL);
    +      $this->assertSession()->fieldNotExists('edit-checkbox-disabled', NULL);
    

    Same

ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar

Working on addressing comment #61.

ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
Status: Needs work » Needs review
FileSize
51.81 KB
9.76 KB

Here I have tried to address points 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 and 24 of comment #61.

The last submitted patch, 58: 3139407-58.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 63: 3139407-63.patch, failed testing. View results

shetpooja04’s picture

Status: Needs work » Needs review
FileSize
51.39 KB
3.29 KB

I have addressed 1 to 6 points suggested in comment #61.
Please review

shetpooja04’s picture

Rerolled the patch in #66

Status: Needs review » Needs work

The last submitted patch, 67: 3139407-66.patch, failed testing. View results

anmolgoyal74’s picture

Status: Needs work » Needs review
FileSize
51.15 KB
1.07 KB
paulocs’s picture

Status: Needs review » Reviewed & tested by the community

Hello,
Patch #70 looks good to me. I didn't find no AssertLegacyTrait::assert(No)FieldById any more.
Moving to RTBC.

Cheers, Paulo.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Looks good but needs a re-roll.

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
FileSize
1.93 KB
51.15 KB

Patch re-rolled.

longwave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll
catch’s picture

One more issue:

+    // Verify if the test passes with button ID.
+    $this->assertSession()->buttonNotExists('i-dont-exist');
+    // Verify if the test passes with button Value.
+    $this->assertSession()->buttonNotExists('I dont exist');
+    // Verify if the test passes with button Name.
+    $this->assertSession()->buttonNotExists('no');

this is failing cspell due to 'dont', probably need to change to i-do-not-exist and I do not exist or I don't exist.

catch’s picture

Status: Reviewed & tested by the community » Needs work
ankithashetty’s picture

Status: Needs work » Needs review
FileSize
51.16 KB
788 bytes

Updated the patch in #73 with the minor corrections mentioned in #75... Kindly review.

Thanks!

mondrake’s picture

#77 addresses #75. RTBC

Is there any plan to have cspell checks as part of DrupalCI test runs?

  • catch committed 71813a8 on 9.1.x
    Issue #3139407 by pavnish, mohrerao, mondrake, shaktik, rahulrasgon,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 71813a8 and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

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