diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..44d8855 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI + +on: + push: + pull_request: + +jobs: + test: + name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}" + + strategy: + matrix: + include: + - mw: 'REL1_35' + php: '8.0' + - mw: 'REL1_38' + php: '8.1' + - mw: 'REL1_39' + php: '8.1' + + runs-on: ubuntu-latest + + defaults: + run: + working-directory: mediawiki + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: mbstring, intl + tools: composer + + - name: Cache MediaWiki + id: cache-mediawiki + uses: actions/cache@v3 + with: + path: | + mediawiki + !mediawiki/extensions/ + !mediawiki/vendor/ + key: mw_${{ matrix.mw }}-php${{ matrix.php }}_v3 + + - name: Cache Composer cache + uses: actions/cache@v3 + with: + path: ~/.composer/cache + key: composer-php${{ matrix.php }} + + - uses: actions/checkout@v3 + with: + path: EarlyCopy + + - name: Install MediaWiki + if: steps.cache-mediawiki.outputs.cache-hit != 'true' + working-directory: ~ + run: bash EarlyCopy/.github/workflows/installMediaWiki.sh ${{ matrix.mw }} SimpleBatchUpload + + - uses: actions/checkout@v3 + with: + path: mediawiki/extensions/SimpleBatchUpload + + - run: composer update + + - name: Run update.php + run: php maintenance/update.php --quick + + - name: Run PHPUnit + run: php tests/phpunit/phpunit.php -c extensions/SimpleBatchUpload/ + + - name: Run PHPUnit with code coverage + run: php tests/phpunit/phpunit.php -c extensions/SimpleBatchUpload/ --coverage-clover coverage.xml + + - name: Upload code coverage + run: bash <(curl -s https://codecov.io/bash) + if: github.ref == 'refs/heads/master' diff --git a/.github/workflows/installMediaWiki.sh b/.github/workflows/installMediaWiki.sh new file mode 100644 index 0000000..ad86546 --- /dev/null +++ b/.github/workflows/installMediaWiki.sh @@ -0,0 +1,35 @@ +#! /bin/bash + +MW_BRANCH=$1 +EXTENSION_NAME=$2 + +wget https://github.com/wikimedia/mediawiki/archive/$MW_BRANCH.tar.gz -nv + +tar -zxf $MW_BRANCH.tar.gz +mv mediawiki-$MW_BRANCH mediawiki + +cd mediawiki + +composer install +php maintenance/install.php --dbtype sqlite --dbuser root --dbname mw --dbpath $(pwd) --pass AdminPassword WikiName AdminUser + +echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php +echo 'ini_set("display_errors", 1);' >> LocalSettings.php +echo '$wgShowExceptionDetails = true;' >> LocalSettings.php +echo '$wgShowDBErrorBacktrace = true;' >> LocalSettings.php +echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php + +echo 'wfLoadExtension( "'$EXTENSION_NAME'" );' >> LocalSettings.php + +cat <> composer.local.json +{ + "extra": { + "merge-plugin": { + "merge-dev": true, + "include": [ + "extensions/$EXTENSION_NAME/composer.json" + ] + } + } +} +EOT diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 7e60197..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,69 +0,0 @@ -build: - # The build contains everything related to running test, deployment and analysis commands. - services: - mariadb: 10 - - dependencies: - override: - - true # do not install any dependencies - tests: - override: - - ~/build/tests/setup/run-tests.sh - - nodes: - code-analysis-and-test-mw-master: - environment: - php: 7.4 - variables: - MW: master - SBU: composer - tests: - override: - - command: ~/build/tests/setup/run-tests.sh --coverage-clover ~/coverage.xml - coverage: - file: ~/coverage.xml - format: clover - - command: phpcs-run - use_website_config: true - - php-scrutinizer-run --enable-security-analysis - test-mw-min-version: - environment: - php: 7.0 - variables: - MW: 1.31.0 - SBU: download - test-mw-1.31: - environment: - php: 7.1 - variables: - MW: 1.31.3 - SBU: composer - test-mw-1.32: - environment: - php: 7.2 - variables: - MW: 1.32.3 - SBU: download - test-mw-1.33: - environment: - php: 7.2 - variables: - MW: 1.33.0 - SBU: download - test-mw-1.34: - environment: - php: 7.3 - variables: - MW: 1.34.0 - SBU: composer - -filter: -# The filter section defines which files are analyzed, where dependencies are located and which files should be completely ignored. - dependency_paths: - - mw - excluded_paths: - - mw/extensions - -build_failure_conditions: {} -# The build failure conditions section allows you to define failure conditions where a build should be failed based on findings in the analysis. -# Findings can be that code coverage has decreased below a certain point, or that new issues have been found, etc. diff --git a/README.md b/README.md index 686e05a..2360a92 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ # SimpleBatchUpload +[![GitHub Workflow Status](https://github.com/ProfessionalWiki/SimpleBatchUpload/actions/workflows/ci.yml/badge.svg)](https://github.com/ProfessionalWiki/SimpleBatchUpload/actions?query=workflow%3ACI) [![Latest Stable Version](https://poser.pugx.org/mediawiki/simple-batch-upload/v/stable)](https://packagist.org/packages/mediawiki/simple-batch-upload) [![Packagist download count](https://poser.pugx.org/mediawiki/simple-batch-upload/downloads)](https://packagist.org/packages/mediawiki/simple-batch-upload) -[![Build Status](https://scrutinizer-ci.com/g/ProfessionalWiki/SimpleBatchUpload/badges/build.png?b=master)](https://scrutinizer-ci.com/g/ProfessionalWiki/SimpleBatchUpload/build-status/master) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ProfessionalWiki/SimpleBatchUpload/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ProfessionalWiki/SimpleBatchUpload/?branch=master) The [SimpleBatchUpload][mw-simple-batch-upload] extension provides basic, no-frills uploading of multiple files to MediaWiki. @@ -13,8 +12,8 @@ It is maintained by [Professional.Wiki](https://professional.wiki/). ## Requirements -- PHP 7.0 or later -- MediaWiki 1.31 or later +- PHP 8.0 or later +- MediaWiki 1.35 or later ## Installation @@ -26,7 +25,7 @@ installation directory. ```json { "require": { - "mediawiki/simple-batch-upload": "^1.0" + "mediawiki/simple-batch-upload": "^2.0" } } ``` @@ -36,8 +35,7 @@ Then add the following line to your "LocalSettings.php" file: wfLoadExtension( 'SimpleBatchUpload' ); ``` -**Note:** To use the extension [`$wgEnableWriteAPI`][$wgEnableWriteAPI] needs to -be enabled and the user needs the [`writeapi`][writeapi] right. Both is the +**Note:** To use the extension the user needs the [`writeapi`][writeapi] right. This is the default MediaWiki setting for registered users, but it may have been changed during the configuration of the wiki. @@ -105,5 +103,4 @@ on mediawiki.org. [license]: https://www.gnu.org/copyleft/gpl.html [mw-simple-batch-upload]: https://www.mediawiki.org/wiki/Extension:SimpleBatchUpload [composer]: https://getcomposer.org/ -[$wgEnableWriteAPI]: https://www.mediawiki.org/wiki/Manual:$wgEnableWriteAPI [writeapi]: https://www.mediawiki.org/wiki/Manual:User_rights#List_of_permissions diff --git a/composer.json b/composer.json index 3a8f5ff..19c703d 100644 --- a/composer.json +++ b/composer.json @@ -21,16 +21,16 @@ "forum": "https://www.mediawiki.org/wiki/Extension_talk:SimpleBatchUpload", "source": "https://github.com/ProfessionalWiki/SimpleBatchUpload", "issues": "https://github.com/ProfessionalWiki/SimpleBatchUpload/issues", - "irc": "irc://irc.freenode.org/mediawiki" + "irc": "irc://libera.chat:6667/mediawiki" }, "require": { - "mediawiki/mediawiki": ">=1.31", - "php": ">=7.0", + "mediawiki/mediawiki": ">=1.35", + "php": ">=8.0", "composer/installers": "^2|^1.0.1" }, "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-master": "2.x-dev" } } } diff --git a/extension.json b/extension.json index 750ff51..95b1ddc 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "SimpleBatchUpload", - "version": "1.9.0", + "version": "2.0.0-dev", "author": [ "[https://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]", "[https://professional.wiki/ Professional.Wiki]", @@ -12,7 +12,7 @@ "license-name": "GPL-2.0-or-later", "type": "specialpage", "requires": { - "MediaWiki": ">=1.31" + "MediaWiki": ">=1.35" }, "MessagesDirs": { "SimpleBatchUpload": [ @@ -29,6 +29,56 @@ "AutoloadNamespaces": { "SimpleBatchUpload\\": "src/" }, - "callback": "SimpleBatchUpload\\SimpleBatchUpload::initCallback", + "TestAutoloadNamespaces": { + "SimpleBatchUpload\\Tests": "tests/phpunit/" + }, + "ExtensionMessagesFiles": { + "SimpleBatchUploadAlias": "src/SimpleBatchUpload.alias.php", + "SimpleBatchUploadMagic": "src/SimpleBatchUpload.magic.php" + }, + "SpecialPages": { + "BatchUpload": "SimpleBatchUpload\\SpecialBatchUpload" + }, + "Hooks": { + "ParserFirstCallInit": "SimpleBatchUpload\\SimpleBatchUpload::registerParserFunction", + "MakeGlobalVariablesScript": "SimpleBatchUpload\\SimpleBatchUpload::onMakeGlobalVariablesScript" + }, + "ResourceFileModulePaths": { + "localBasePath": "res", + "remoteExtPath": "SimpleBatchUpload/res" + }, + "ResourceModules": { + "ext.SimpleBatchUpload.jquery-file-upload": { + "scripts": [ + "jquery.fileupload.js" + ], + "styles": [ + "jquery.fileupload.css" + ], + "position": "top", + "dependencies": [ + "jquery.ui" + ] + }, + "ext.SimpleBatchUpload": { + "scripts": [ + "ext.SimpleBatchUpload.js" + ], + "styles": [ + "ext.SimpleBatchUpload.css" + ], + "position": "top", + "dependencies": [ + "ext.SimpleBatchUpload.jquery-file-upload", + "mediawiki.Title", + "mediawiki.jqueryMsg", + "mediawiki.api" + ], + "messages": [ + "simplebatchupload-comment", + "simplebatchupload-max-files-alert" + ] + } + }, "manifest_version": 2 } diff --git a/release-notes.md b/release-notes.md index 8e0d86b..c5aa5f7 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,5 +1,15 @@ ## Release Notes +### SimpleBatchUpload 2.0.0 + +Under development. + +* Raised minimum required versions to + * MediaWiki 1.35 + * PHP 8.0 +* Added PHP 8.1 support (thanks @malberts) +* Fixed deprecation warning in MediaWiki 1.38 (thanks @malberts) + ### SimpleBatchUpload 1.9.0 Released on December 14, 2022. diff --git a/res/ext.SimpleBatchUpload.js b/res/ext.SimpleBatchUpload.js index cc79265..4398500 100644 --- a/res/ext.SimpleBatchUpload.js +++ b/res/ext.SimpleBatchUpload.js @@ -95,10 +95,6 @@ var tokenType = 'csrf'; - if ( mw.config.get( 'wgVersion' ) < '1.27.0' ) { - tokenType = 'edit'; - } - // invalidate cached token; always request a new one api.badToken( tokenType ); diff --git a/src/SimpleBatchUpload.php b/src/SimpleBatchUpload.php index 5e14033..4e8ebfa 100644 --- a/src/SimpleBatchUpload.php +++ b/src/SimpleBatchUpload.php @@ -22,6 +22,7 @@ namespace SimpleBatchUpload; +use MediaWiki\MediaWikiServices; use Parser; /** @@ -31,146 +32,23 @@ */ class SimpleBatchUpload { - /** - * @var array Max files could be uploaded per batch - */ - protected $maxFilesPerBatchConfig; - - public static function initCallback() { - - $simpleBatchUpload = new self(); - $simpleBatchUpload->registerEarlyConfiguration( $GLOBALS ); - } - - public function registerEarlyConfiguration( &$targetConfiguration ){ - $sourceConfiguration = $this->getEarlyConfiguration(); - $this->mergeConfiguration( $sourceConfiguration, $targetConfiguration ); - } - - public function registerLateConfiguration( &$targetConfiguration ){ - $sourceConfiguration = $this->getLateConfiguration(); - $this->mergeConfiguration( $sourceConfiguration, $targetConfiguration ); - } - - /** - * @param array $targetConfiguration - */ - protected function mergeConfiguration( $sourceConfiguration, &$targetConfiguration ) { - foreach ( $sourceConfiguration as $varname => $value ) { - $targetConfiguration[ $varname ] = array_key_exists( $varname, $targetConfiguration )?array_replace_recursive( $targetConfiguration[ $varname ], $value ):$value; - } - } - - protected function getEarlyConfiguration(): array { - - $configuration = []; - - $configuration[ 'wgExtensionMessagesFiles' ][ 'SimpleBatchUploadAlias' ] = __DIR__ . '/SimpleBatchUpload.alias.php'; - $configuration[ 'wgExtensionMessagesFiles' ][ 'SimpleBatchUploadMagic' ] = __DIR__ . '/SimpleBatchUpload.magic.php'; - - $configuration[ 'wgSpecialPages' ][ 'BatchUpload' ] = '\SimpleBatchUpload\SpecialBatchUpload'; - - $configuration[ 'wgHooks' ][ 'ParserFirstCallInit' ][ 'ext.simplebatchupload' ] = [ $this, 'registerParserFunction' ]; - $configuration[ 'wgHooks' ][ 'MakeGlobalVariablesScript' ][ 'ext.simplebatchupload' ] = [ $this, 'onMakeGlobalVariablesScript' ]; - $configuration[ 'wgHooks' ][ 'SetupAfterCache' ][ 'ext.simplebatchupload' ] = [ $this, 'onSetupAfterCache']; - - return $configuration; - } - - protected function getLateConfiguration(): array { - - $configuration = []; - $configuration[ 'wgResourceModules' ] = $this->getUploadSupportModuleDefinition() + $this->getUploadModuleDefinition(); - - return $configuration; - } - /** * @param \Parser $parser * * @return bool * @throws \MWException */ - public function registerParserFunction( &$parser ) { + public static function registerParserFunction( &$parser ) { $parser->setFunctionHook( 'batchupload', [ new UploadButtonRenderer(), 'renderParserFunction' ], Parser::SFH_OBJECT_ARGS ); return true; } - protected function getUploadSupportModuleDefinition(): array { - if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.35.0', '>=' ) ) { - $dependencies = [ 'jquery.ui' ]; - } else { - $dependencies = [ 'jquery.ui.widget' ]; - } - - return [ 'ext.SimpleBatchUpload.jquery-file-upload' => - - $this->getBasePathsForNonComposerModules() + - - [ - 'scripts' => [ 'res/jquery.fileupload.js' ], - 'styles' => [ 'res/jquery.fileupload.css' ], - 'position' => 'top', - 'dependencies' => $dependencies, - ], - ]; - } - - protected function getUploadModuleDefinition(): array { - - $dependencies = [ 'ext.SimpleBatchUpload.jquery-file-upload', 'mediawiki.Title', 'mediawiki.jqueryMsg' ]; - - if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.32.0', '>' ) ) { - $dependencies[] = 'mediawiki.api'; - } else { - $dependencies[] = 'mediawiki.api.edit'; - } - - return [ 'ext.SimpleBatchUpload' => - - $this->getBasePathsForNonComposerModules() + - - [ - 'scripts' => [ 'res/ext.SimpleBatchUpload.js' ], - 'styles' => [ 'res/ext.SimpleBatchUpload.css' ], - 'position' => 'top', - 'dependencies' => $dependencies, - 'messages' => [ 'simplebatchupload-comment', 'simplebatchupload-max-files-alert' ], - ], - ]; - } - - /** - * @return string[] - */ - protected function getBasePathsForNonComposerModules(): array { - return [ - 'localBasePath' => dirname( __DIR__ ), - 'remoteBasePath' => $GLOBALS[ 'wgExtensionAssetsPath' ] . '/SimpleBatchUpload', - ]; - } - /** * @param array &$vars * @param \OutputPage $out */ - public function onMakeGlobalVariablesScript( &$vars, $out ) { - $vars['simpleBatchUploadMaxFilesPerBatch'] = $this->getMaxFilesPerBatchConfig(); - } - - public function onSetupAfterCache() { - $this->registerLateConfiguration( $GLOBALS ); + public static function onMakeGlobalVariablesScript( &$vars, $out ) { + $vars['simpleBatchUploadMaxFilesPerBatch'] = MediaWikiServices::getInstance()->getMainConfig()->get( 'SimpleBatchUploadMaxFilesPerBatch' ); } - /** - * @return array - */ - public function getMaxFilesPerBatchConfig() { - - if ( $this->maxFilesPerBatchConfig === null ) { - $this->maxFilesPerBatchConfig = $GLOBALS[ 'wgSimpleBatchUploadMaxFilesPerBatch' ]; - } - - return $this->maxFilesPerBatchConfig; - } } diff --git a/src/UploadButtonRenderer.php b/src/UploadButtonRenderer.php index 7c55f9f..a96d23b 100644 --- a/src/UploadButtonRenderer.php +++ b/src/UploadButtonRenderer.php @@ -111,7 +111,7 @@ protected function getHtml( ParameterProvider $paramProvider ) { * @param \ParserOutput | \OutputPage $output */ protected function addModulesToOutput( $output ) { - $output->addModules( 'ext.SimpleBatchUpload' ); + $output->addModules( [ 'ext.SimpleBatchUpload' ] ); $output->addModuleStyles( [ 'ext.SimpleBatchUpload', 'ext.SimpleBatchUpload.jquery-file-upload' ] ); } diff --git a/tests/phpunit/SimpleBatchUploadTest.php b/tests/phpunit/SimpleBatchUploadTest.php index d0db92e..fa2cac5 100644 --- a/tests/phpunit/SimpleBatchUploadTest.php +++ b/tests/phpunit/SimpleBatchUploadTest.php @@ -20,6 +20,10 @@ * @ingroup SimpleBatchUpload */ +namespace SimpleBatchUpload\Tests; + +use OutputPage; +use Parser; use SimpleBatchUpload\SimpleBatchUpload; /** @@ -28,7 +32,7 @@ * * @since 1.5 */ -class SimpleBatchUploadTest extends PHPUnit_Framework_TestCase { +class SimpleBatchUploadTest extends \PHPUnit\Framework\TestCase { public function testCanConstruct() { @@ -38,28 +42,6 @@ public function testCanConstruct() { ); } - public function testRegistersGlobals() { - $this->assertJsonConfiguration( $GLOBALS ); - $this->assertEarlyConfiguration( $GLOBALS ); - $this->assertLateConfiguration( $GLOBALS ); - } - - public function testRegisterEarlyConfiguraion() { - $sbu = new SimpleBatchUpload(); - $config = []; - - $sbu->registerEarlyConfiguration( $config ); - $this->assertEarlyConfiguration( $config ); - } - - public function testRegisterLateConfiguraion() { - $sbu = new SimpleBatchUpload(); - $config = []; - - $sbu->registerLateConfiguration( $config ); - $this->assertLateConfiguration( $config ); - } - public function testRegisterParserFunction() { $parser = $this->getMockBuilder( Parser::class ) @@ -99,69 +81,4 @@ public function assertJsonConfiguration( $configuration ) { $this->assertArrayHasKey( 'wgSimpleBatchUploadMaxFilesPerBatch', $configuration ); } - /** - * @param $configuration - */ - public function assertEarlyConfiguration( $configuration ) { - - //$configuration[ 'wgExtensionMessagesFiles' ][ 'SimpleBatchUploadAlias' ] = __DIR__ . '/SimpleBatchUpload.alias.php'; - //$configuration[ 'wgExtensionMessagesFiles' ][ 'SimpleBatchUploadMagic' ] = __DIR__ . '/SimpleBatchUpload.magic.php'; - $this->assertArrayHasKey( 'wgExtensionMessagesFiles', $configuration ); - $this->assertArrayHasKey( 'SimpleBatchUploadAlias', $configuration[ 'wgExtensionMessagesFiles' ] ); - $this->assertArrayHasKey( 'SimpleBatchUploadMagic', $configuration[ 'wgExtensionMessagesFiles' ] ); - - //$configuration[ 'wgSpecialPages' ][ 'BatchUpload' ] = '\SimpleBatchUpload\SpecialBatchUpload'; - $this->assertArrayHasKey( 'wgSpecialPages', $configuration ); - $this->assertArrayHasKey( 'BatchUpload', $configuration[ 'wgSpecialPages' ] ); - - //$configuration[ 'wgHooks' ][ 'ParserFirstCallInit' ][ 'ext.simplebatchupload' ] = [ $this, 'registerParserFunction' ]; - //$configuration[ 'wgHooks' ][ 'MakeGlobalVariablesScript' ][ 'ext.simplebatchupload' ] = [ $this, 'onMakeGlobalVariablesScript' ]; - //$configuration[ 'wgHooks' ][ 'SetupAfterCache' ][ 'ext.simplebatchupload' ] = [ $this, 'onSetupAfterCache']; - $this->assertArrayHasKey( 'wgHooks', $configuration ); - - foreach ( [ 'ParserFirstCallInit', 'MakeGlobalVariablesScript', 'SetupAfterCache' ] as $hook ) { - $this->assertArrayHasKey( $hook, $configuration[ 'wgHooks' ] ); - $this->assertArrayHasKey( 'ext.simplebatchupload', $configuration[ 'wgHooks' ][ $hook ] ); - $this->assertTrue( is_callable( $configuration[ 'wgHooks' ][ $hook ][ 'ext.simplebatchupload' ] ) ); - } - } - - /** - * @param $configuration - */ - public function assertLateConfiguration( $configuration ) { - - $this->assertArrayHasKey( 'wgResourceModules', $configuration ); - - $this->assertArrayHasKey( 'ext.SimpleBatchUpload.jquery-file-upload', $configuration[ 'wgResourceModules' ] ); - $this->assertTrue( $configuration[ 'wgResourceModules' ][ 'ext.SimpleBatchUpload.jquery-file-upload' ] === [ - 'localBasePath' => dirname( dirname( __DIR__ ) ), - 'remoteBasePath' => $GLOBALS[ 'wgExtensionAssetsPath' ] . '/SimpleBatchUpload', - 'scripts' => [ 'res/jquery.fileupload.js' ], - 'styles' => [ 'res/jquery.fileupload.css' ], - 'position' => 'top', - 'dependencies' => [ 'jquery.ui.widget' ], - ] ); - - $dependencies = [ 'ext.SimpleBatchUpload.jquery-file-upload', 'mediawiki.Title', 'mediawiki.jqueryMsg' ]; - - if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.32.0', '>' ) ) { - $dependencies[] = 'mediawiki.api'; - } else { - $dependencies[] = 'mediawiki.api.edit'; - } - - $this->assertArrayHasKey( 'ext.SimpleBatchUpload', $configuration[ 'wgResourceModules' ] ); - $this->assertTrue( $configuration[ 'wgResourceModules' ][ 'ext.SimpleBatchUpload' ] === [ - 'localBasePath' => dirname( dirname( __DIR__ ) ), - 'remoteBasePath' => $GLOBALS[ 'wgExtensionAssetsPath' ] . '/SimpleBatchUpload', - 'scripts' => [ 'res/ext.SimpleBatchUpload.js' ], - 'styles' => [ 'res/ext.SimpleBatchUpload.css' ], - 'position' => 'top', - 'dependencies' => $dependencies, - 'messages' => [ 'simplebatchupload-comment', 'simplebatchupload-max-files-alert' ], - ]); - - } - -} \ No newline at end of file +} diff --git a/tests/setup/fix-composer.php b/tests/setup/fix-composer.php deleted file mode 100644 index c15cc29..0000000 --- a/tests/setup/fix-composer.php +++ /dev/null @@ -1,57 +0,0 @@ - composer.local.json -# -# * Reads composer.json-like from stdin -# * Adds requirement for the specified composer package ($argv[1] and $argv[2]) and a repo ($argv[3]) -# * Writes the result to stdout -# -# @copyright (C) 2016 - 2019, Stephan Gambke -# @license GNU General Public License, version 2 (or any later version) - -error_reporting( E_ALL | E_STRICT ); - -/** - * @return string - */ -function read(): string { - $in = ''; - - while ( $f = fgets( STDIN ) ) { - $in .= $f; - } - - return $in; -} - -/** - * @param string $in - * @param string[] $params - * - * @return array - */ -function process( string $in, array $params ) { - $json = json_decode( $in, true ); - - $json[ 'require' ][ $params[ 1 ] ] = $params[ 2 ]; - - $json[ 'repositories' ] = [ - [ - 'type' => 'vcs', - 'url' => 'https://github.com' . substr( $params[ 3 ], 1 ) . '.git', - ], - ]; - - return $json; -} - - -/** - * @param $json - */ -function write( $json ) { - print json_encode( $json, JSON_PRETTY_PRINT ); -} - -$in = read(); -$out = process( $in, $argv ); -write( $out ); diff --git a/tests/setup/run-tests.sh b/tests/setup/run-tests.sh deleted file mode 100755 index 0e699e0..0000000 --- a/tests/setup/run-tests.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/bash -# Run tests -# (assumes to be run on scrutinizer.org) -# -# @copyright (C) 2016 - 2019, Stephan Gambke -# @license GNU General Public License, version 2 (or any later version) - -set -xe - -function fetch_mw_from_download() { - - wget "https://releases.wikimedia.org/mediawiki/${MW%.*}/mediawiki-$MW.tar.gz" - tar -zxf "mediawiki-$MW.tar.gz" - mv "mediawiki-$MW" ~/mw - - cd ~/mw - composer require "phpunit/phpunit:^6.5" --update-no-dev --no-scripts -} - -function fetch_mw_from_composer() { - - wget https://github.com/wikimedia/mediawiki/archive/$MW.tar.gz - tar -zxf $MW.tar.gz - mv mediawiki-$MW ~/mw - - cd ~/mw - composer install -} - -function fetch_sbu_from_download() { - cp -R ~/build ~/mw/extensions/SimpleBatchUpload -} - -function fetch_sbu_from_composer() { - - local COMPOSER_VERSION='' - - if [[ "$SCRUTINIZER_PR_SOURCE_BRANCH" == '' ]] - then - COMPOSER_VERSION="dev-${SCRUTINIZER_BRANCH}#${SCRUTINIZER_SHA1}" - else - COMPOSER_VERSION="dev-${SCRUTINIZER_PR_SOURCE_BRANCH}#${SCRUTINIZER_SHA1}" - fi - - php ~/build/tests/setup/fix-composer.php "mediawiki/simple-batch-upload" "$COMPOSER_VERSION" "$SCRUTINIZER_PROJECT" <~/mw/composer.local.json-sample >~/mw/composer.local.json - - cd ~/mw - composer update "mediawiki/simple-batch-upload" -} - -function install() { - mysql -e 'create database wikidb;' - php ~/mw/maintenance/install.php --dbserver $SERVICE_MARIADB_IP --dbuser root --dbname wikidb --pass hugo TestWiki admin - echo "wfLoadExtension( 'SimpleBatchUpload' );" >>~/mw/LocalSettings.php -} - -function run_tests() { - php ~/mw/tests/phpunit/phpunit.php -c ~/mw/extensions/SimpleBatchUpload/phpunit.xml.dist "$@" -} - -function prepare_analysis() { - cd ~/build - mv ~/mw ~/build -} - -if [[ "$MW" =~ 1.[[:digit:]][[:digit:]].[[:digit:]][[:digit:]]? ]] # e.g. 1.33.0 -then - fetch_mw_from_download -else - fetch_mw_from_composer -fi - -if [[ "$SBU" == "download" ]] -then - fetch_sbu_from_download -else - fetch_sbu_from_composer -fi - -install - -run_tests "$@" - -prepare_analysis \ No newline at end of file