Page MenuHomePhabricator

Figure out what to do with uses of Repo classes in Lib and Client tests
Closed, ResolvedPublic

Description

The Wikibase Lib and Client extensions have several PHPUnit tests that reference classes from Repo. While most of those tests auto-disable themselves if Repo is not installed, we’d still like to avoid this. It’s not yet clear how to do this, though.

Event Timeline

I have been thinking about this, I looked at the two tests that have a bad dependency. Both seems to be legitimate cases, I have thought moving them to another component, or moving them to a shared place but couldn't come up with a good solution.

For LuaWikibaseIntegrationTest: I have no idea.

For EntityChangeLookupTest: Move ChangeStore and SqlChangeStore from repo to lib to be next to EntityChangeLookup. For example for term store, we move the write logic to lib while only repo uses the write logic.

Change 609271 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[mediawiki/extensions/Wikibase@master] Move SqlChangeStore from repo to lib

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

Change 609271 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Move SqlChangeStore from repo to lib

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

Still we need to something about LuaWikibaseIntegrationTest

I looked a bit into LuaWikibaseIntegrationTest and I’m also unsure what to do with that. The test saves an example item to WikibaseRepo’s entity store, creates a test module, and then tests the result of parsing various bits of wikitext that invoke that module.

We could try to remove the dependency on WikibaseRepo by instead overriding WikibaseClient’s services (entity lookup etc.) to return the example item. But then the test becomes pretty similar to other tests, which already install a MockClientStore, and ultimately it’s not really an integration test anymore: it doesn’t test the full connection between Wikibase Repo and Client.

If we say that this is a test which needs the WikibaseRepo extension to be installed, and that’s fine, but we want to avoid the direct coupling to the WikibaseRepo PHP class, then there are other ways to avoid that. We could, for example, save the example item using an API call. Come to think of it, we could also use API calls to create the test module, and to do the various test parses… maybe we can turn this test into a MediaWiki API integration test?

Change 609461 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Skip SqlChangeStoreTest in Client-only mode

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

Change 609461 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Skip SqlChangeStoreTest in Client-only mode

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

Verification instructions: check that Travis CI builds are green again.

If we say that this is a test which needs the WikibaseRepo extension to be installed, and that’s fine, but we want to avoid the direct coupling to the WikibaseRepo PHP class, then there are other ways to avoid that. We could, for example, save the example item using an API call. Come to think of it, we could also use API calls to create the test module, and to do the various test parses… maybe we can turn this test into a MediaWiki API integration test?

I quite like the idea of creating them through API requests, this is coupling to the public interface that's much more stable than the code itself.

Verification instructions: check that Travis CI builds are green again.

(They are, by the way.)

Hm, one thing that API integration tests can’t do is this:

$this->setAllowDataAccessInUserLanguage( false );

But I think we should be able to deal with that. I don’t see a lot of other config changes in that test.

Change 609779 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] WIP: API integration test for Lua

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

Change 612563 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Use $wgCirrusSearchDisableUpdate in CI config

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

Change 612564 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Remove PHP LuaWikibaseIntegrationTest

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

Change 609779 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Rewrite LuaWikibaseIntegrationTest as API integration test

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

Change 612563 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Use $wgCirrusSearchDisableUpdate in CI config

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

Change 612564 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Remove PHP LuaWikibaseIntegrationTest

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

$ GIT_PAGER=cat git grep -F 'Wikibase\Repo\' lib/ client/
client/includes/Api/PageTerms.php:use Wikibase\Repo\WikibaseRepo;

No more test uses \o/