Problem/Motivation

Discovered via PHPStan in #3178534: Start running PHPStan on Drupal core (level 0) we have some test code that returns or otherwise uses the void result of a PHPUnit method, e.g.

 ------ --------------------------------------------------------------------- 
  Line   core/modules/comment/tests/src/Functional/CommentPagerTest.php       
 ------ --------------------------------------------------------------------- 
  227    Result of method PHPUnit\Framework\Assert::assertEquals() (void) is  
         used.                                                                
 ------ --------------------------------------------------------------------- 

 ------ ------------------------------------------------------------------------------------------ 
  Line   core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php  
 ------ ------------------------------------------------------------------------------------------ 
  271    Result of method PHPUnit\Framework\Assert::assertEquals() (void) is                       
         used.                                                                                     
 ------ ------------------------------------------------------------------------------------------ 

 ------ ------------------------------------------------------------------------- 
  Line   core/modules/editor/tests/src/Functional/EditorUploadImageScaleTest.php  
 ------ ------------------------------------------------------------------------- 
  231    Result of method PHPUnit\Framework\Assert::assertEquals() (void) is      
         used.                                                                    
  232    Result of method PHPUnit\Framework\Assert::assertEquals() (void) is      
         used.                                                                    
 ------ ------------------------------------------------------------------------- 

Steps to reproduce

For a full set of results see https://www.drupal.org/pift-ci-job/2114597 or any later run from the parent issue.

Proposed resolution

Fix these cases.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#3 3222783.patch8.67 KBlongwave
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

These are relatively new, this is probably due to #3131281: Replace assertEqual() with assertEquals()

longwave’s picture

Status: Active » Needs review
FileSize
8.67 KB
longwave’s picture

Title: Result of void PHPUnit method is used » Result of method PHPUnit\Framework\Assert::assertEquals() (void) is used
mondrake’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3131900: Refactor assertions that assign return values to variables

RTBC, let's cleanup dead returns. Is anything from #3131900: Refactor assertions that assign return values to variables still relevant after this, or can we close it outdated?

longwave’s picture

Forgot about that one. Let's see what remains after this is committed.

  • catch committed e76b29a on 9.3.x
    Issue #3222783 by longwave, mondrake: Result of method PHPUnit\Framework...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed e76b29a and pushed to 9.3.x. Thanks!

  • catch committed 9d89220 on 9.2.x
    Issue #3222783 by longwave, mondrake: Result of method PHPUnit\Framework...

Status: Fixed » Closed (fixed)

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