Problem/Motivation

Running core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php on PHP 8.1 causes deprecation error on PHP 8.1

Steps to reproduce

Run \Drupal\Tests\system\Functional\FileTransfer\FileTransferTest on PHP 8.1 (Note there are other deprecations caused by other, separate, issues)

Proposed resolution

Fix the test.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new763 bytes

Before

PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.0RC3-dev
Configuration: /Users/alex/dev/sites/drupal8alt.dev/phpunit.xml
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\system\Functional\FileTransfer\FileTransferTest
.                                                                   1 / 1 (100%)

Time: 00:04.624, Memory: 10.00 MB

OK (1 test, 3 assertions)

Unsilenced deprecation notices (3)

  2x: urlencode(): Passing null to parameter #1 ($string) of type string is deprecated
    2x in FileTransferTest::testJail from Drupal\Tests\system\Functional\FileTransfer

  1x: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated
    1x in FileTransferTest::testJail from Drupal\Tests\system\Functional\FileTransfer

After

PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.1.0RC3-dev
Configuration: /Users/alex/dev/sites/drupal8alt.dev/phpunit.xml
Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing Drupal\Tests\system\Functional\FileTransfer\FileTransferTest
.                                                                   1 / 1 (100%)

Time: 00:03.447, Memory: 10.00 MB

OK (1 test, 3 assertions)

Unsilenced deprecation notices (1)

  1x: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated
    1x in FileTransferTest::testJail from Drupal\Tests\system\Functional\FileTransfer
alexpott’s picture

andypost’s picture

+++ b/core/modules/system/tests/src/Functional/FileTransfer/TestFileTransfer.php
@@ -8,10 +8,10 @@
-  protected $username = NULL;
-  protected $password = NULL;

looks only username and password used in urlencode()

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

andypost’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new699 bytes
new614 bytes

I mean that should be enough

alexpott’s picture

Can we go back to #2 please. @andypost Meh this is test code so it really doesn’t matter - it would change them all because it means that the next time someone looks at the test you don’t have to wonder why

alexpott’s picture

Actually the more I think about it the more I care that all the values are the same. Making people not have to wonder why things are the way they are in a test saves people time.

alexpott’s picture

Status: Needs review » Needs work
andypost’s picture

Status: Needs work » Needs review
StatusFileSize
new813 bytes
new904 bytes

Sorry, fixed docs as this properties are defined in parent class (strictly nullable)

alexpott’s picture

@andypost that looks great! Nice one.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Straightforward.

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed 241acb9 and pushed to 9.3.x. Thanks!

  • larowlan committed 241acb9 on 9.3.x
    Issue #3241272 by andypost, alexpott: core/modules/system/tests/src/...

Status: Fixed » Closed (fixed)

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