Thanks for this wonderful module, creating an issue here so we can track progress on this issue.

The Drupal 9 readiness tool for modules ("mglaman/drupal-check": "^1.0" https://github.com/mglaman/drupal-check) correctly flags several of the PHPUnit test associated with CAS module as using deprecated code.

8  Line   modules/contrib/cas/tests/src/Unit/CasPropertyBagTest.php  
9 ------ ----------------------------------------------------------- 
10  26     Call to deprecated method readAttribute() of class         
11         PHPUnit\Framework\Assert:                                  
12         https://github.com/sebastianbergmann/phpunit/issues/3338   
13  27     Call to deprecated method readAttribute() of class         
14         PHPUnit\Framework\Assert:                                  
15         https://github.com/sebastianbergmann/phpunit/issues/3338   
16  40     Call to deprecated method readAttribute() of class         
17         PHPUnit\Framework\Assert:                                  
18         https://github.com/sebastianbergmann/phpunit/issues/3338   
19  41     Call to deprecated method readAttribute() of class         
20         PHPUnit\Framework\Assert:                                  
21         https://github.com/sebastianbergmann/phpunit/issues/3338   
22  53     Call to deprecated method readAttribute() of class         
23         PHPUnit\Framework\Assert:                                  
24         https://github.com/sebastianbergmann/phpunit/issues/3338   
25  68     Call to deprecated method readAttribute() of class         
26         PHPUnit\Framework\Assert:                                  
27         https://github.com/sebastianbergmann/phpunit/issues/3338   
28 ------ ----------------------------------------------------------- 
29
30 ------ --------------------------------------------------------------------- 
31  Line   modules/contrib/cas/tests/src/Unit/Routing/CasRouteEnhancerTest.php  
32 ------ --------------------------------------------------------------------- 
33  98     Call to deprecated method assertArraySubset() of class               
34         PHPUnit\Framework\Assert:                                            
35         https://github.com/sebastianbergmann/phpunit/issues/3494             
36 ------ --------------------------------------------------------------------- 
37
38 ------ ------------------------------------------------------------------- 
39  Line   modules/contrib/cas/tests/src/Unit/Service/CasProxyHelperTest.php  
40 ------ ------------------------------------------------------------------- 
41  232    Call to deprecated method setExpectedException() of class          
42         Drupal\Tests\UnitTestCase:                                         
43         in drupal:8.8.0 and is removed from drupal:9.0.0.                  
44         Backward compatibility for PHPUnit 4 will no longer be supported.  
45 ------ ------------------------------------------------------------------- 
46
47 ------ ------------------------------------------------------------------- 
48  Line   modules/contrib/cas/tests/src/Unit/Service/CasUserManagerTest.php  
49 ------ ------------------------------------------------------------------- 
50  202    Call to deprecated method setExpectedException() of class          
51         Drupal\Tests\UnitTestCase:                                         
52         in drupal:8.8.0 and is removed from drupal:9.0.0.                  
53         Backward compatibility for PHPUnit 4 will no longer be supported.  
54  255    Call to deprecated method setExpectedException() of class          
55         Drupal\Tests\UnitTestCase:                                         
56         in drupal:8.8.0 and is removed from drupal:9.0.0.                  
57         Backward compatibility for PHPUnit 4 will no longer be supported.  
58  389    Call to deprecated method setExpectedException() of class          
59         Drupal\Tests\UnitTestCase:                                         
60         in drupal:8.8.0 and is removed from drupal:9.0.0.                  
61         Backward compatibility for PHPUnit 4 will no longer be supported.  
62  480    Call to deprecated method setExpectedException() of class          
63         Drupal\Tests\UnitTestCase:                                         
64         in drupal:8.8.0 and is removed from drupal:9.0.0.                  
65         Backward compatibility for PHPUnit 4 will no longer be supported.  
66 ------ ------------------------------------------------------------------- 
67
68 ------ ------------------------------------------------------------------- 
69  Line   modules/contrib/cas/tests/src/Unit/Service/CasValidatorTest.php    
70 ------ ------------------------------------------------------------------- 
71  283    Call to deprecated method setExpectedException() of class          
72         Drupal\Tests\UnitTestCase:                                         
73         in drupal:8.8.0 and is removed from drupal:9.0.0.                  
74         Backward compatibility for PHPUnit 4 will no longer be supported.  
75 ------ ------------------------------------------------------------------- 
76
77 [ERROR] Found 13 errors                                                        

Rewrite of tests needed according to this blog post by PHPUnit maintainer https://thephp.cc/news/2019/02/help-my-tests-stopped-working#assertarray...

Comments

trackleft2 created an issue. See original summary.

trackleft2’s picture

Title: drupal-check Drupal 9 forward compatibility checker flags PHPUnit tests as not compativle. » drupal-check Drupal 9 forward compatibility checker flags PHPUnit tests as not compatible.
bkosborne’s picture

Thanks for reporting! I'll be sure to get to this in the coming months.

Status: Needs review » Needs work

The last submitted patch, 4: 3110204-forward-compatibility-drupal-check.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

trackleft2’s picture

StatusFileSize
new3.49 KB
new6.09 KB

getPgt is a function, adding ()

trackleft2’s picture

Status: Needs work » Needs review
xem8vfdh’s picture

I believe there is also a composer.json change that should be made to add the Drupal 9 support badge to the module's main page, as explained here: https://www.drupal.org/project/auto_entitylabel/issues/3111526

EDIT: or perhaps the change needs to be made to the core_version_requirement field in the module's .info file. Here's an example from another project: https://www.drupal.org/files/issues/2020-03-12/3119389-d9-upgrade-2.patch

EDIT 2: My info above is incorrect, apologies.

xem8vfdh’s picture

Status: Needs review » Needs work
trackleft2’s picture

@xeM8VfDh I probably haven't had enough coffee this morning, but what I think you are saying is that we should update the info file with v9 compatibility now that we've resolved all of the drupal deprecation warnings?

CAS already says it is compatible with v9 here: https://git.drupalcode.org/project/cas/-/blob/8.x-1.x/cas.info.yml#L5 and is, as long as you don't run any phpunit tests.

xem8vfdh’s picture

hey @trackleft. I think I was wrong about the composer and info changes. Apparently there is some switch a module maintainer can flip somewhere that marks their module as being D9 compatible, and show the aforementioned badge. I am not sure where that switch is, since I'm not a maintainer. Sorry.

trackleft2’s picture

Status: Needs work » Needs review

No problem at all @xeM8VfDh

xem8vfdh’s picture

StatusFileSize
new6.27 KB

I applied 3110204-6-forward-compatibility-drupal-check.patch against 8.x-1.x and received the following warnings/errors:

$ git apply -v 3110204-6-forward-compatibility-drupal-check.patch
3110204-6-forward-compatibility-drupal-check.patch:20: trailing whitespace.
 
3110204-6-forward-compatibility-drupal-check.patch:31: trailing whitespace.
 
3110204-6-forward-compatibility-drupal-check.patch:40: trailing whitespace.
 
3110204-6-forward-compatibility-drupal-check.patch:49: trailing whitespace.
 
Checking patch 3110204-forward-compatibility-drupal-check.patch...
Checking patch tests/src/Unit/CasPropertyBagTest.php...
Checking patch tests/src/Unit/Routing/CasRouteEnhancerTest.php...
Applied patch 3110204-forward-compatibility-drupal-check.patch cleanly.
Applied patch tests/src/Unit/CasPropertyBagTest.php cleanly.
Applied patch tests/src/Unit/Routing/CasRouteEnhancerTest.php cleanly.
warning: 4 lines add whitespace errors.

Before I applied the patch, I got 15 errors from drupal check. When I ran it again after applying the patch, I get these remianing 8:

$ ./vendor/bin/drupal-check modules/cas/
 63/63 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ --------------------------------------------------------------------------- 
  Line   src/Commands/CasCommands.php                                               
 ------ --------------------------------------------------------------------------- 
         Class Drush\Commands\DrushCommands not found and could not be autoloaded.  
  10     Class Drush\Commands\DrushCommands not found and could not be autoloaded.  
 ------ --------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------- 
  Line   tests/src/Unit/Service/CasProxyHelperTest.php                                         
 ------ -------------------------------------------------------------------------------------- 
  232    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
 ------ -------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------- 
  Line   tests/src/Unit/Service/CasUserManagerTest.php                                         
 ------ -------------------------------------------------------------------------------------- 
  202    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
  255    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
  389    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
  480    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
 ------ -------------------------------------------------------------------------------------- 

 ------ -------------------------------------------------------------------------------------- 
  Line   tests/src/Unit/Service/CasValidatorTest.php                                           
 ------ -------------------------------------------------------------------------------------- 
  283    Call to deprecated method setExpectedException() of class Drupal\Tests\UnitTestCase:  
         in drupal:8.8.0 and is removed from drupal:9.0.0.                                     
         Backward compatibility for PHPUnit 4 will no longer be supported.                     
 ------ -------------------------------------------------------------------------------------- 

                                                                                                                        
 [ERROR] Found 8 errors

I'm attaching 3110204-7.patch, which includes the changes from 3110204-6-forward-compatibility-drupal-check.patch and also resolves the deprecations noted above:

$ ./vendor/bin/drupal-check modules/cas/
 63/63 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
                                                                                                
 [OK] No errors

When I reapplied my patch against 8.x-1.x, I did not get the same warnings/errors I did with 3110204-6-forward-compatibility-drupal-check.patch.

bkosborne’s picture

Status: Needs review » Fixed

Thank you all very much for your work on this. I really appreciate it. I verified the test fixes and am committing.

  • bkosborne committed 2c56325 on 8.x-1.x authored by trackleft2
    Issue #3110204 by trackleft2, xeM8VfDh: drupal-check Drupal 9 forward...

Status: Fixed » Closed (fixed)

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