[go: up one dir, main page]

Page MenuHomePhabricator

Make PHPUnit dataProvider static in Wikibase tests
Open, Needs TriagePublic

Description

The @dataProvider annotation should be a static function, check and make data provider in the extension static and adjust the usages (More infos at T332865).

Some abstract provider function are also used in other extensions and need some compatibility code.

Initial work was done in e875e0b021d4d727adc57f89f1890eb789dae758

Event Timeline

Note: the vast majority of data providers in Wikibase are named either provideSomething or somethingProvider, so searching for public function provide or public function .*Provider\( should find the majority of functions that haven’t been converted yet. (git grep '@data[pP]rovider' | grep -v -e '@data[pP]rovider provide' -e '@data[pP]rovider .*Provider\b' shows a few dozen other data providers that are named differently; those will have to be checked manually whether they’re static or not, as it can’t be seen from the @dataProvider line.)

Change 924543 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] view: Make test data providers static (*Provider)

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

It turns out this task has also (like T337153) had some initial work done already: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/921633

@Umherirrender, if you’re going to create a bunch of tasks for various extensions to do the same thing, and also upload changes partially doing that thing to those extensions, can you please attach those changes to those tasks, so that others can actually see the connection?

Change 924548 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] client: Make some data providers static (provide*)

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

It turns out this task has also (like T337153) had some initial work done already: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/921633

@Umherirrender, if you’re going to create a bunch of tasks for various extensions to do the same thing, and also upload changes partially doing that thing to those extensions, can you please attach those changes to those tasks, so that others can actually see the connection?

My initial work was against T332865 and thus all patch sets are marked with that task. After I have finished the work I have looked which data provider are not converted and opened a task for each extension, in the most task I mention the still open data provider I have found, but for Wikibase there are so much tests with so much data provider and it was not possible and seems not useful to mention all of them. I also have assumed when the task gets worked on the developer starts with a up-to-date local clone and would see the already converted data provider in the code and can go with the non-static ones. I am going to update the other tasks to mention the merged patch set.

Change 924543 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] view: Make test data providers static (*Provider)

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

Change 924548 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] client: Make some data providers static (provide*)

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

Change 927136 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] MediawikiEditEntityTest: Improve data providers

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

Change 927136 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] MediawikiEditEntityTest: Improve data providers

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

Change #1082197 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] [WIP] Make dataProvider function static

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

Change #1082819 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 1

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

Change #1082197 abandoned by Audrey Penven:

[mediawiki/extensions/Wikibase@master] [WIP] Make dataProvider function static

Reason:

this commit is too large. breaking it into several smaller ones

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

Change #1082821 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 2

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

Change #1082822 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 3

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

Change #1082824 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 4

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

The 4 patch sets fix the dataProvider functions in 59 files. I thought these were reasonably sized chunks to review, but am open to combining them, or breaking them up further as needed.

I've identified 26 files still remaining, which require more complex solutions. Those are still in progress.

Change #1084182 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] [WIP] make dataProviders static

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

Change #1082819 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 1

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

Change #1082821 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 2

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

Change #1085439 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/WikibaseMediaInfo@master] Support making Wikibase dataProviders static

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

Change #1085588 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/WikibaseMediaInfo@master] Temporarily skip DeserializationTesters

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

Change #1085588 merged by jenkins-bot:

[mediawiki/extensions/WikibaseMediaInfo@master] Temporarily skip DeserializationTesters

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

Change #1082822 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 3

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

Change #1082824 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Make phpunit dataProviders static, part 4

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

Change #1085439 merged by jenkins-bot:

[mediawiki/extensions/WikibaseMediaInfo@master] Support making Wikibase dataProviders static

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

Another batch of these is ready for review: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/1084182

After this, there are 5 test files remaining (that I was able to find):

  • repo/tests/phpunit/includes/ChangeOp/ChangeOpsTest.php
  • repo/tests/phpunit/includes/Content/EntityContentTestCase.php
  • repo/tests/phpunit/includes/Content/EntityHandlerTestCase.php
  • repo/tests/phpunit/includes/Content/ItemContentTest.php
  • repo/tests/phpunit/includes/Specials/SpecialNewEntityTestCase.php

These are abstract classes, or otherwise are used by tests in other extensions. Changing them involves a multi-step process of skipping tests in the other repo, making the functions static in Wikibase, making the function implementations static in the other repos (WikibaseLexeme and WikibaseCirrusSearch) and re-enabling the tests there. I think it makes the most sense to do the commit chains with the smallest set of changes needed, rather than include it in the patchset linked above.

Change #1084182 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Make dataProviders static in tests with mocks

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

Change #1090877 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] [WIP] dataProvider staticization in EntityProvider

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

Change #1091780 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/WikibaseCirrusSearch@master] Skip tests to facilitate making Wikibase dataProviders static

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

Change #1091781 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/WikibaseCirrusSearch@master] Re-enable tests, make dataProviders static

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