[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Added experimental support for PHPUnit
Seb35 has submitted this change and it was merged. Change subject: Added experimental support for PHPUnit .. Added experimental support for PHPUnit Given this extension is quite unusual, a very specific installation must be used. It is detailled in docs/internals.rst. For now there are only basic tests. Change-Id: Ie02c51fdd3cefd546f1d68206b700a748d27e142 --- M docs/config/farms.php M docs/config/farms.yml A docs/internals.rst M extension.json M src/MediaWikiFarm.php A tests/phpunit/MediaWikiFarmTest.php A tests/phpunit/data/config/farms.php 7 files changed, 132 insertions(+), 9 deletions(-) Approvals: Seb35: Verified; Looks good to me, approved diff --git a/docs/config/farms.php b/docs/config/farms.php index aa4140b..114ad86 100644 --- a/docs/config/farms.php +++ b/docs/config/farms.php @@ -22,7 +22,7 @@ # Configuration similar to the Wikimedia farm 'wikimedia' => array( - 'server' => '(?[a-z-]+)\.(?[a-z]+)\.org', + 'server' => '(?P[a-z-]+)\.(?[a-z]+)\.org', 'variables' => array( @@ -56,7 +56,7 @@ # Configuration for a small wiki farm 'com-example' => array( - 'server' => '(?[a-z]+)-(?[a-z]+)\.example\.com', + 'server' => '(?P[a-z]+)-(?[a-z]+)\.example\.com', 'variables' => array( @@ -90,7 +90,7 @@ 'com-example-redirect' => array( - 'server' => '(?[a-z]+)_(?[a-z]+)\.example\.com', + 'server' => '(?P[a-z]+)_(?[a-z]+)\.example\.com', 'redirect' => '$client-$wiki.example.com', ), ); diff --git a/docs/config/farms.yml b/docs/config/farms.yml index 301cc97..f2ba1ba 100644 --- a/docs/config/farms.yml +++ b/docs/config/farms.yml @@ -12,7 +12,7 @@ ## Configuration similar to the Wikimedia farm #wikimedia: # -#server: '(?[a-z-]+)\.(?[a-z]+)\.org' +#server: '(?P[a-z-]+)\.(?[a-z]+)\.org' # #variables: # @@ -39,7 +39,7 @@ ## Configuration for a small wiki farm #com-example: # -#server: '(?[a-z]+)-(?[a-z]+)\.example\.com' +#server: '(?P[a-z]+)-(?[a-z]+)\.example\.com' # #variables: # @@ -66,5 +66,5 @@ # #com-example-redirect: # -#server: '(?[a-z]+)_(?[a-z]+)\.example\.com' +#server: '(?P[a-z]+)_(?[a-z]+)\.example\.com' #redirect: '$client-$wiki.example.com' diff --git a/docs/internals.rst b/docs/internals.rst new file mode 100644 index 000..a4ca3a8 --- /dev/null +++ b/docs/internals.rst @@ -0,0 +1,24 @@ +* +Internals +* + +Overview + + +Most of the code is inside the class MediaWikiFarm, except the code used to load the global configuration parameters inside the global scope. + +The class MediaWikiFarm is in charge of loading the farm configuration, managing the configuration cache, selectionning the requested farm and wiki, compiling the configuration for a given wiki. The executable file :path:`src/main.php` is the strict equivalent of LocalSettings.php: it loads the configuration parameters inside the global scope. + +There are a lot of various configurations, depending on the mono- or multi-version installation, on the PHP version, on the MediaWiki version, and on the PHP SAPI used (Web or CLI). Various flags and :code:`require_once` are used to select the right files and functions to load the configuration. The main difficulty is to correctly handle the CLI case, mainly because MediaWiki is mostly designed to have only one wiki per installation. + +Testing +=== + +MediaWikiFarm has an experimental support of unit tests with `PHPUnit`_. + +Because of the very specific use case of PHPUnit called in CLI, it is recommended to set up a classical wiki installation with a classical LocalSettings.php with its own database and (fakely) load MediaWikiFarm with :code:`wfLoadExtension( 'MediaWikiFarm' )`. In fact this will not load the MediaWikiFarm executable code due to a lack of of support of extension registration (difficult problem in this case), so this will only load the class MediaWikiFarm needed to execute unit tests. + +Then, to execute PHPUnit, go to root MediaWiki directory and run :command:`php tests/phpunit/phpunit.php --group MediaWikiFarm`. You can add :command:`--debug` if you want more details. + +.. _PHPUnit: http://www.phpunit.de + diff --git a/extension.json b/extension.json index 0bc62e5..15f80cf 100644 --- a/extension.json +++ b/extension.json @@ -21,6 +21,11 @@ "i18n" ] }, + "Hooks": { + "UnitTestsList": [ + "MediaWikiFarm::onUnitTestsList" + ] + }, "AutoloadClasses": { "MediaWikiFarm": "src/MediaWikiFarm.php" }, diff --git
[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Added experimental support for PHPUnit
Seb35 has uploaded a new change for review. https://gerrit.wikimedia.org/r/302110 Change subject: Added experimental support for PHPUnit .. Added experimental support for PHPUnit Given this extension is quite unusual, a very specific installation must be used. It is detailled in docs/internals.rst. For now there are only basic tests. Change-Id: Ie02c51fdd3cefd546f1d68206b700a748d27e142 --- M docs/config/farms.php M docs/config/farms.yml A docs/internals.rst M extension.json M src/MediaWikiFarm.php A tests/phpunit/MediaWikiFarmTest.php A tests/phpunit/data/config/farms.php 7 files changed, 132 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm refs/changes/10/302110/1 diff --git a/docs/config/farms.php b/docs/config/farms.php index aa4140b..114ad86 100644 --- a/docs/config/farms.php +++ b/docs/config/farms.php @@ -22,7 +22,7 @@ # Configuration similar to the Wikimedia farm 'wikimedia' => array( - 'server' => '(?[a-z-]+)\.(?[a-z]+)\.org', + 'server' => '(?P[a-z-]+)\.(?[a-z]+)\.org', 'variables' => array( @@ -56,7 +56,7 @@ # Configuration for a small wiki farm 'com-example' => array( - 'server' => '(?[a-z]+)-(?[a-z]+)\.example\.com', + 'server' => '(?P[a-z]+)-(?[a-z]+)\.example\.com', 'variables' => array( @@ -90,7 +90,7 @@ 'com-example-redirect' => array( - 'server' => '(?[a-z]+)_(?[a-z]+)\.example\.com', + 'server' => '(?P[a-z]+)_(?[a-z]+)\.example\.com', 'redirect' => '$client-$wiki.example.com', ), ); diff --git a/docs/config/farms.yml b/docs/config/farms.yml index 301cc97..f2ba1ba 100644 --- a/docs/config/farms.yml +++ b/docs/config/farms.yml @@ -12,7 +12,7 @@ ## Configuration similar to the Wikimedia farm #wikimedia: # -#server: '(?[a-z-]+)\.(?[a-z]+)\.org' +#server: '(?P[a-z-]+)\.(?[a-z]+)\.org' # #variables: # @@ -39,7 +39,7 @@ ## Configuration for a small wiki farm #com-example: # -#server: '(?[a-z]+)-(?[a-z]+)\.example\.com' +#server: '(?P[a-z]+)-(?[a-z]+)\.example\.com' # #variables: # @@ -66,5 +66,5 @@ # #com-example-redirect: # -#server: '(?[a-z]+)_(?[a-z]+)\.example\.com' +#server: '(?P[a-z]+)_(?[a-z]+)\.example\.com' #redirect: '$client-$wiki.example.com' diff --git a/docs/internals.rst b/docs/internals.rst new file mode 100644 index 000..a4ca3a8 --- /dev/null +++ b/docs/internals.rst @@ -0,0 +1,24 @@ +* +Internals +* + +Overview + + +Most of the code is inside the class MediaWikiFarm, except the code used to load the global configuration parameters inside the global scope. + +The class MediaWikiFarm is in charge of loading the farm configuration, managing the configuration cache, selectionning the requested farm and wiki, compiling the configuration for a given wiki. The executable file :path:`src/main.php` is the strict equivalent of LocalSettings.php: it loads the configuration parameters inside the global scope. + +There are a lot of various configurations, depending on the mono- or multi-version installation, on the PHP version, on the MediaWiki version, and on the PHP SAPI used (Web or CLI). Various flags and :code:`require_once` are used to select the right files and functions to load the configuration. The main difficulty is to correctly handle the CLI case, mainly because MediaWiki is mostly designed to have only one wiki per installation. + +Testing +=== + +MediaWikiFarm has an experimental support of unit tests with `PHPUnit`_. + +Because of the very specific use case of PHPUnit called in CLI, it is recommended to set up a classical wiki installation with a classical LocalSettings.php with its own database and (fakely) load MediaWikiFarm with :code:`wfLoadExtension( 'MediaWikiFarm' )`. In fact this will not load the MediaWikiFarm executable code due to a lack of of support of extension registration (difficult problem in this case), so this will only load the class MediaWikiFarm needed to execute unit tests. + +Then, to execute PHPUnit, go to root MediaWiki directory and run :command:`php tests/phpunit/phpunit.php --group MediaWikiFarm`. You can add :command:`--debug` if you want more details. + +.. _PHPUnit: http://www.phpunit.de + diff --git a/extension.json b/extension.json index 0bc62e5..15f80cf 100644 --- a/extension.json +++ b/extension.json @@ -21,6 +21,11 @@ "i18n" ] }, + "Hooks": { + "UnitTestsList": [ + "MediaWikiFarm::onUnitTestsList" + ] + }, "AutoloadClasses": {