Currently the unit test flysystem_s3/tests/src/Unit/AwsCacheAdapterTest.php fails after upgrading to Drupal 9 using version 2.0.0-rc1.

PHP Fatal error: Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found in /var/www/site/web/modules/contrib/flysystem_s3/tests/src/Unit/AwsCacheAdapterTest.php

Would we be able to transition to using PHPUnit\Framework\Testcase?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jonarcher created an issue. See original summary.

jnlar’s picture

StatusFileSize
new662 bytes

Attached patch.

jnlar’s picture

leon kessler’s picture

Title: Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found » Update tests to work with Drupal 9
Version: 2.0.0-rc1 » 2.0.x-dev
Assigned: jnlar » leon kessler
Category: Bug report » Task

Ran the patch through the test runner on the new 2.0.x-dev branch, there's another fail. Updating the issue summary to cover this one as well.

leon kessler’s picture

Seems to be different errors running through gitlab than as a patch. Uploading changes from the MR as a patch file to confirm.

leon kessler’s picture

Status: Active » Needs review
StatusFileSize
new5.85 KB

Okay I'm hoping this will be enough to get the tests to pass, let's see...

leon kessler’s picture

StatusFileSize
new5.97 KB

Previous patch didn't include the file rename ModuleInstallUninstallWebTest correctly.

leon kessler’s picture

Woohooo! I think this can be merged in. But the tests could really do with a cleanup, I'll probably open another issue for that.

A few notes:

  • I've used 'public' => TRUE on anything that calls $plugin->getExternalUrl, as otherwise it hits FlysystemUrlTrait::getExternalUrl(), which in turn uses the UrlGenerator service. Whilst this can be mocked, it means we're not really testing that much functionality from the flysystem_s3 module. I'm not exactly sure how the tests were originally passing without 'public' => TRUE being set, but I feel like anything calling getExternalUrl() on the S3 plugin probably should be public. And that probably we need separate tests for private and public config.
  • I'm not really sure what the NoDrupal namespaces were about, but these were causing errors so I updated them to Drupal.
  • The tests are lacking comments and some don't have particularly great names (e.g. public function test())
leon kessler’s picture

Made a few small improvements in latest patch:

  • Added comments to each test
  • Updated name of function test() to testGetExternalUrl
  • Removed function testIamAuth that had no assertions.

  • Leon Kessler authored 66bb7ac on 2.0.x
    Issue #3254472 by Leon Kessler, jonarcher: Update tests to work with...
leon kessler’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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