WikibaseLexeme
MediaWiki WikibaseLexeme extension
|
Running tests
The recommended way of setting up the development environment is with the use of the mwcli tool. To create a local MediaWiki development environment using this tool, see the docker development environment guide in the tool's documentation.
Note: All following command examples will be using the mwcli tool, but can also be run with docker or on bare metal according to preference.
The WikibaseLexeme extension also requires Wikibase to be set up and configured in your local MediaWiki instance. To get up and running with Wikibase, follow the installation instructions on MediaWiki.
Both Wikibase and WikibaseLexeme rely on the composer merge plugin for MediaWiki. To ensure the plugin is configured correctly, double check your composer.local.json
file in your local MediaWiki directory against the instructions on the MediaWiki website.
Clone this repository to the extensions/
directory in your local MediaWiki directory:
To initialize and update git submodules run:
Add the following line to LocalSettings.php
at the root of you MediaWiki directory, to enable the extension:
To ensure all composer dependencies are installed, run composer from the root of your MediaWiki instance:
Install all npm dependencies in order to use node development tools and scripts, using mwcli fresh:
The code for the Special:NewLexeme special page lives in a separate Git repository, included as a submodule under resources/special/new-lexeme/
. That directory is not directly used at runtime, but rather the build results from it are stored in this repository under resources/special/new-lexeme-dist/
. The following command updates the submodule to the latest main
branch and adds a new build to Git, ready to be committed here:
This command should be run from time to time (but not necessarily for every new commit in the submodule). Note: this command must be run outside a container.
When you are working with the submodule, and want to see the current status of your work, you can use the following command to build and copy whatever is currently in the directory:
Then go to Special:NewLexeme on your wiki and see the result.
Historical note: during development, the current special page was called Special:NewLexemeAlpha, and Special:NewLexeme was a separate (older) implementation of similar functionality, which was eventually replaced with the new implementation. You might come across the NewLexemeAlpha name in git logs or similar.
PHP tests can be found in tests/phpunit directory.
You can run tests using composer as so:
More information about running PHP unit tests with mwcli can be found in the mwcli interaction instructions.
JavaScript tests are to be found in two directories:
tests/qunit
(tests depending on MediaWiki)tests/jasmine
(do not require MediaWiki)JavaScript tests are run using MediaWiki test runner, except for tests of several UI widgets which are independent from MediaWiki which can by run using nodejs.
MediaWiki runner could run JavaScript tests of the extension by either opening the Special:JavaScriptTest page in the browser, or by running the following in the main directory of the MediaWiki installation (this will run all QUnit tests of the MediaWiki installation):
Jasmine tests could be run from the WikibaseLexeme main directoday using:
For more information see the [Mediawiki manual for Javascript tests](https://www.mediawiki.org/wiki/Manual:JavaScript_unit_testing.
Please see its README.
Configuration files for several linters etc are also provided. The easiest way to run these along with tests, is to either run mw dev mediawiki composer test
(for PHP code), or mw dev mediawiki fresh grunt test
(for JavaScript part).