jenkins-bot has submitted this change and it was merged.
Change subject: Improve testing infrastructure
..
Improve testing infrastructure
* Instead of a hacky 'sed -i' in composer.json, dynamically declare the class
MediaWikiTestCase if missing (when PHPUnit is called directly).
* Check if phpdbg is installed, else use php
* Skip two tests when running HHVM because of issue #4797
"Multiple calls of 'include' do not check for file modification HHVM 3.5.0"
https://github.com/facebook/hhvm/issues/4797
Possibly a workaround will be later added, but for now try to render
MediaWikiFarm compatible with WMF CI suites
* Fixed two phpcs issues
* Dynamically create two JSON files with bad syntax (used in a test) to avoid
trigerring a CI error report
* Made phpdoc optional for now
Bug: T151879
Change-Id: I17604c11e773f74f2c8b7ccb6aa7919cb729d552
---
M composer.json
M src/MediaWikiFarm.php
M tests/phpunit/ConfigurationTest.php
M tests/phpunit/MediaWikiFarmTestCase.php
M tests/phpunit/MultiversionInstallationTest.php
D tests/phpunit/data/config/badsyntax.json
D tests/phpunit/data/config/empty.json
7 files changed, 35 insertions(+), 17 deletions(-)
Approvals:
Seb35: Looks good to me, approved
jenkins-bot: Verified
diff --git a/composer.json b/composer.json
index 7a94498..61956c2 100644
--- a/composer.json
+++ b/composer.json
@@ -16,27 +16,21 @@
},
"require-dev": {
"justinrainbow/json-schema": "~3.0",
- "phpdocumentor/phpdocumentor": "*",
"phpunit/phpunit": "~4.8",
"jakub-onderka/php-parallel-lint": "*",
"phpmd/phpmd": "*",
"mediawiki/mediawiki-codesniffer": "*"
},
+ "suggest": {
+ "phpdocumentor/phpdocumentor": "*"
+ },
"scripts": {
"validate-schema": "php ./bin/validate-schema.php",
"lint": "parallel-lint --exclude vendor .",
"phpcs": "phpcs -p -s",
- "phpdoc": "phpdoc -d bin,src -t ./docs/code",
- "phpunit": [
- "sed -i 's/extends MediaWikiTestCase/extends
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
- "phpdbg -qrr `which phpunit` --strict-coverage",
- "sed -i 's/extends PHPUnit_Framework_TestCase/extends
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
- ],
- "unit": [
- "sed -i 's/extends MediaWikiTestCase/extends
PHPUnit_Framework_TestCase/' tests/phpunit/MediaWikiFarmTestCase.php",
- "phpunit --no-coverage",
- "sed -i 's/extends PHPUnit_Framework_TestCase/extends
MediaWikiTestCase/' tests/phpunit/MediaWikiFarmTestCase.php"
- ],
+ "phpdoc": "[ \"`which phpdoc`\" = \"\" ] || phpdoc -d bin,src
-t ./docs/code",
+ "phpunit": "which phpdbg && phpdbg -qrr `which phpunit`
--strict-coverage || phpunit --strict-coverage",
+ "unit": "phpunit --no-coverage",
"test": [
"composer lint",
"composer unit",
diff --git a/src/MediaWikiFarm.php b/src/MediaWikiFarm.php
index 7d47050..8a324ad 100644
--- a/src/MediaWikiFarm.php
+++ b/src/MediaWikiFarm.php
@@ -539,7 +539,9 @@
}
# Shortcut loading
+ // @codingStandardsIgnoreStart
if( $this->cacheDir && ( $result = $this->readFile(
'versions.php', $this->cacheDir, false ) ) && array_key_exists( $host, $result
) ) {
+ // @codingStandardsIgnoreEnd
$result = $result[$host];
$fresh = true;
$myfreshness = filemtime( $this->cacheDir .
'/versions.php' );
diff --git a/tests/phpunit/ConfigurationTest.php
b/tests/phpunit/ConfigurationTest.php
index 4c03391..7e4b13d 100644
--- a/tests/phpunit/ConfigurationTest.php
+++ b/tests/phpunit/ConfigurationTest.php
@@ -182,7 +182,6 @@
$farm->checkExistence();
$farm->getMediaWikiConfig();
$settings = $farm->getConfiguration( 'settings' );
- #$this->assertEquals( [], $settings );
$extensions = $farm->getConfiguration( 'extensions' );
$skins = $farm->getConfiguration( 'skins' );
$this->assertTrue(
$settings['wgUseExtensionTestExtensionBiLoading'] );
diff --git a/tests/phpunit/MediaWikiFarmTestCase.php
b/tests/phpunit/MediaWikiFarmTestCase.php
index 9b5e037..d9493b6 100644
--- a/tests/phpunit/MediaWikiFarmTestCase.php
+++ b/tests/phpunit/MediaWikiFarmTestCase.php
@@ -9,6 +9,13 @@
require_once dirname( dirname( dirname( __FILE__ ) ) ) .
'/src/AbstractMediaWikiFarmScript.php';
+# These tests can be called either directly with PHPUnit or through the
PHPUnit