Page MenuHomePhabricator

assertArraySubset() will be removed in PHPUnit 9
Closed, ResolvedPublic

Description

I cut a few lines from Traivs CI:

assertArraySubset() is deprecated and will be removed in PHPUnit 9.

tests/phpunit/MediaWikiIntegrationTestCase.php:416
maintenance/doMaintenance.php:99

assertArraySubset() used for:

[root@Alice mediawiki]# grep -nr "\bassertArraySubset\b" tests/
tests/phpunit/structure/ApiStructureTest.php:447:					$this->assertArraySubset(
tests/phpunit/PHPUnit6And8Compat.php:32:				'assertArraySubset\(\)',
tests/phpunit/includes/skins/SkinTemplateTest.php:105:		$this->assertArraySubset(
tests/phpunit/includes/specials/ContribsPagerTest.php:34:		$this->assertArraySubset( $expectedOpts, ContribsPager::processDateFilter( $inputOpts ) );
tests/phpunit/includes/api/ApiBlockInfoTraitTest.php:25:		$this->assertArraySubset( $subset, $info );
tests/phpunit/includes/api/ApiQueryBlocksTest.php:54:		$this->assertArraySubset( $subset, $data['query']['blocks'][0] );
tests/phpunit/includes/api/ApiQueryBlocksTest.php:84:		$this->assertArraySubset( $subset, $data['query']['blocks'][0] );
tests/phpunit/includes/api/ApiQueryBlocksTest.php:144:		$this->assertArraySubset( $flagSubset, $data['query']['blocks'][0] );
tests/phpunit/includes/api/ApiQueryBlocksTest.php:170:		$this->assertArraySubset( $restrictionsSubset, $data['query']['blocks'][0] );
tests/phpunit/includes/api/ApiQueryRecentChangesIntegrationTest.php:168:		$this->assertArraySubset(
tests/phpunit/includes/api/ApiQueryRecentChangesIntegrationTest.php:424:		$this->assertArraySubset(
tests/phpunit/includes/api/ApiQueryRecentChangesIntegrationTest.php:474:		$this->assertArraySubset(
tests/phpunit/includes/api/ApiQueryRecentChangesIntegrationTest.php:498:		$this->assertArraySubset( [ 'anon' => true ], $items[0] );
tests/phpunit/includes/api/ApiQueryRecentChangesIntegrationTest.php:1017:		$this->assertArraySubset(
tests/phpunit/includes/PagePropsTest.php:147:	 * does not yet include assertArraySubset(), we needed to code the

Task in Github about deprecating the method.

Event Timeline

We need to port assertArraySubset() to mediawiki. We have two plans:

  1. Copy the code to MediaWikiTestCaseTrait.
  2. Or add https://packagist.org/packages/dms/phpunit-arraysubset-asserts as a dev dependency and call it.

See T192167#5685401. Alternatively, we may also just stop using assertArraySubset.

This warnings are fairly spammy, so it would be nice to have a replacement method.

Adding a replacement method to …IntegrationTest is probably the simplest way forward?

Adding a replacement method to …IntegrationTest is probably the simplest way forward?

In MediaWikiTestCaseTrait, I'd say. We could either implement our own simplified version of assertArraySubset (probably better), or pull an external library with the full version.

Also, I'd recommend not to name it "assertArraySubset".

Adding a replacement method to …IntegrationTest is probably the simplest way forward?

In MediaWikiTestCaseTrait, I'd say.

I thought we were trying to keep that as light as possible (for the sake of MediaWikiUnitTestCase)? But I see it's already got a few similar methods. Fine.

We could either implement our own simplified version of assertArraySubset (probably better), or pull an external library with the full version.

Also, I'd recommend not to name it "assertArraySubset".

Definitely.

Is anyone working on this atm?

Is anyone working on this atm?

I don't think so, mainly because it's not clear how to proceed. Although probably, given how much assertArraySubset is used, we should probably just implement our own simplified version of it.

Is anyone working on this atm?

I don't think so, mainly because it's not clear how to proceed. Although probably, given how much assertArraySubset is used, we should probably just implement our own simplified version of it.

I would just go with that for now. It can always be changed later. Maybe callers that can easily use something else can be migrated too (if any).

Change 581786 had a related patch set uploaded (by Aaron Schulz; owner: Aaron Schulz):
[mediawiki/core@master] Add MediaWikiIntegrationTestCase::assertArraySubmapSame()

https://gerrit.wikimedia.org/r/581786

Change 581786 merged by jenkins-bot:
[mediawiki/core@master] Add MediaWikiIntegrationTestCase::assertArraySubmapSame()

https://gerrit.wikimedia.org/r/581786

aaron claimed this task.