Problem/Motivation

BulkDeleteTest.php file contains few foreach loops with $id which is not used.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

snehalgaikwad created an issue. See original summary.

snehalgaikwad’s picture

Assigned: snehalgaikwad » Unassigned
Status: Active » Needs review
FileSize
1.38 KB
longwave’s picture

+++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php
@@ -345,7 +345,7 @@ public function testPurgeField() {
     $hooks = [];
     $entities = $this->entitiesByBundles[$bundle];
-    foreach ($entities as $id => $entity) {
+    foreach ($entities as $entity) {
       $hooks['field_test_field_delete'][] = $entity;
     }
     $this->checkHooksInvocations($hooks, $actual_hooks);

Unless I am missing something with what checkHooksInvocations() does, this could be simplified to something like

    $hooks['field_test_field_delete'] = $this->entitiesByBundles[$bundle];
    $this->checkHooksInvocations($hooks, $actual_hooks);
shetpooja04’s picture

Status: Needs review » Needs work

I am working on it for further changes

shetpooja04’s picture

Status: Needs work » Needs review
FileSize
1.73 KB
1.56 KB

I have made the changes as per the suggestion in #3
Please review

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, this is nice small improvement.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 5b454e760f to 9.1.x and 3567851c11 to 9.0.x and cf9848243c to 8.9.x. Thanks!

Backported to 8.9.x as this is test only

  • alexpott committed 5b454e7 on 9.1.x
    Issue #3163687 by shetpooja04, snehalgaikwad, longwave: Unused variable...

  • alexpott committed 3567851 on 9.0.x
    Issue #3163687 by shetpooja04, snehalgaikwad, longwave: Unused variable...

  • alexpott committed cf98482 on 8.9.x
    Issue #3163687 by shetpooja04, snehalgaikwad, longwave: Unused variable...

Status: Fixed » Closed (fixed)

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