Page MenuHomePhabricator

Fix PHPUnit deprecations in Platform API
Open, Needs TriagePublic

Description

At the moment, if you run any test, you will be hit with this deprecation message, even if the test passes:

$ docker compose exec api vendor/bin/phpunit --filter PublicWikiControllerTest
PHPUnit 10.5.63 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.31
Configuration: /var/www/html/phpunit.xml

D                                                                   1 / 1 (100%)

Time: 00:00.070, Memory: 36.00 MB

OK, but there were issues!
Tests: 1, Assertions: 2, PHPUnit Deprecations: 6.

This command can be used to get the actual message behind those notices

$  docker compose exec api vendor/bin/phpunit --filter PublicWikiControllerTest --display-phpunit-deprecations --display-deprecations
PHPUnit 10.5.63 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.31
Configuration: /var/www/html/phpunit.xml

D                                                                   1 / 1 (100%)

Time: 00:00.071, Memory: 36.00 MB

6 tests triggered 6 PHPUnit deprecations:

1) Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithValidProfile with data set #0 (['data_hub', 'narrow', 'permanent'])
Providing invalid named argument $boring profile with no other for method Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithValidProfile() is deprecated and will not be supported in PHPUnit 11.0.

/var/www/html/tests/Helper/ProfileValidatorTest.php:12

2) Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithValidProfile with data set #1 (['data_hub', 'other', 'my cat', 'other', 'only in the past'])
Providing invalid named argument $with other values for method Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithValidProfile() is deprecated and will not be supported in PHPUnit 11.0.

/var/www/html/tests/Helper/ProfileValidatorTest.php:12

3) Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile with data set #0 (['data_hub', 'narrow', 'other'])
Providing invalid named argument $missing other keys for method Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile() is deprecated and will not be supported in PHPUnit 11.0.

/var/www/html/tests/Helper/ProfileValidatorTest.php:21

4) Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile with data set #1 (['data_hub', '', 'other'])
Providing invalid named argument $audience is empty string for method Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile() is deprecated and will not be supported in PHPUnit 11.0.

/var/www/html/tests/Helper/ProfileValidatorTest.php:21

5) Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile with data set #2 (['data_lab', 'narrow', 'permanent'])
Providing invalid named argument $audience key present when purpose not data_hub for method Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile() is deprecated and will not be supported in PHPUnit 11.0.

/var/www/html/tests/Helper/ProfileValidatorTest.php:21

6) Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile with data set #3 (['data_hub', 'asdfasdf', 'narrow', 'permanent'])
Providing invalid named argument $other keys when there should not be for method Tests\Jobs\ProfileValidatorTest::testProfileValidatorWorksWithInvalidProfile() is deprecated and will not be supported in PHPUnit 11.0.

/var/www/html/tests/Helper/ProfileValidatorTest.php:21

OK, but there were issues!
Tests: 1, Assertions: 2, PHPUnit Deprecations: 6.

The 6 deprecations are all PHPUnit deprecations from one file tests/Helper/ProfileValidatorTest.php. And the message shows: “Providing invalid named argument ... is deprecated and will not be supported in PHPUnit 11.0.” even though we are still on phpunit^10.5
It seems like they are warning us before we accidentally update to phpunit 11 and break out test suite.

Event Timeline

outdooracorn closed https://github.com/wbstack/api/pull/1153

Fix data providers in ProfileValidatorTest

dang removed dang as the assignee of this task.Wed, Jun 3, 2:01 PM
dang moved this task from In Peer Review to Done on the Wikibase Cloud (Kanban Board) board.
dang removed a project: Patch-For-Review.