diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..35450e2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: smw +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: ['https://www.semantic-mediawiki.org/wiki/Sponsorship'] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..533d4f0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,92 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: + +jobs: + + test: + + runs-on: ubuntu-22.04 + continue-on-error: ${{ matrix.experimental }} + + strategy: + matrix: + include: + # SMW 6.0.1 has a bug where #ask returns empty results in the prepareContentForEdit + # context used by JSONScript parser-type tests. Upgraded to dev-master as workaround; + # pin to 7.x once released. See: https://github.com/SemanticMediaWiki/SemanticResultFormats/pull/1020 + - mediawiki_version: '1.43' + smw_version: dev-master + pf_version: 6.0.5 + php_version: 8.1 + database_type: mysql + database_image: "mariadb:11.2" + coverage: false + experimental: false + - mediawiki_version: '1.43' + smw_version: dev-master + pf_version: 6.0.5 + php_version: 8.3 + database_type: mysql + database_image: "mariadb:11.2" + coverage: true + experimental: false + - mediawiki_version: '1.44' + smw_version: dev-master + pf_version: 6.0.5 + php_version: 8.2 + database_type: mysql + database_image: "mariadb:11.2" + coverage: false + experimental: false + - mediawiki_version: '1.45' + smw_version: dev-master + pf_version: 6.0.5 + php_version: 8.3 + database_type: mysql + database_image: "mariadb:11.2" + coverage: false + experimental: false + + env: + MW_VERSION: ${{ matrix.mediawiki_version }} + SMW_VERSION: ${{ matrix.smw_version }} + PF_VERSION: ${{ matrix.pf_version }} + PHP_VERSION: ${{ matrix.php_version }} + DB_TYPE: ${{ matrix.database_type }} + DB_IMAGE: ${{ matrix.database_image }} + MM_VERSION: ${{ matrix.mm_version }} + + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Update submodules + run: git submodule update --init --remote + + - name: Run tests + run: make ci + if: matrix.coverage == false + + - name: Run tests with coverage + run: make ci-coverage + if: matrix.coverage == true + + - name: Run Phan static analysis + run: make install composer-phan + if: matrix.coverage == true + + - name: Upload code coverage + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage/php/coverage.xml + if: matrix.coverage == true diff --git a/.gitignore b/.gitignore index 98b092a..5f8e4da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,22 @@ -.svn +!.* *~ *.kate-swp .*.swp + +.idea/ + +.envrc +.phpunit.result.cache + +composer.lock +composer.phar + +npm-debug.log + +vendor/ +extensions/ +node_modules/ +conf/ +.DS_Store +.env +coverage diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2d846d0 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build"] + path = build + url = https://github.com/gesinn-it-pub/docker-compose-ci.git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a6cf737 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +-include .env +export + +# setup for docker-compose-ci build directory +# delete "build" directory to update docker-compose-ci + +ifeq (,$(wildcard ./build/)) + $(shell git submodule update --init --remote) +endif + +EXTENSION=SemanticSignup + +# docker images +MW_VERSION?=1.43 +PF_VERSION ?= 6.0.5 +PHP_VERSION?=8.1 +DB_TYPE?=mysql +DB_IMAGE?="mariadb:11.2" + +# extensions +SMW_VERSION?=dev-master + +# composer +# Enables "composer update" inside of extension +COMPOSER_EXT?=true + +# nodejs +# Enables node.js related tests and "npm install" +# NODE_JS?=true + +# check for build dir and git submodule init if it does not exist +include build/Makefile diff --git a/README.md b/README.md index 2400410..82d2501 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ # Semantic Signup -[![Build Status](https://secure.travis-ci.org/SemanticMediaWiki/SemanticSignup.svg?branch=master)](http://travis-ci.org/SemanticMediaWiki/SemanticSignup) -[![Code Coverage](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticSignup/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticSignup/?branch=master) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticSignup/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticSignup/?branch=master) +[![CI](https://github.com/SemanticMediaWiki/SemanticSignup/actions/workflows/ci.yml/badge.svg)](https://github.com/SemanticMediaWiki/SemanticSignup/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/SemanticMediaWiki/SemanticSignup/graph/badge.svg)](https://codecov.io/gh/SemanticMediaWiki/SemanticSignup) [![Latest Stable Version](https://poser.pugx.org/mediawiki/semantic-signup/version.png)](https://packagist.org/packages/mediawiki/semantic-signup) [![Packagist download count](https://poser.pugx.org/mediawiki/semantic-signup/d/total.png)](https://packagist.org/packages/mediawiki/semantic-signup) + Semantic Signup (a.k.a. SES) is a [Semantic Mediawiki][smw] extension that uses Semantic Forms to improve the user registration process. ## Requirements -- PHP 5.3.2 or later -- MediaWiki 1.19 or later -- [Semantic MediaWiki][smw] 1.9+ -- [Semantic Forms][sf] 2.8+ +- PHP 8.1 or later +- MediaWiki 1.43 or later +- [Semantic MediaWiki][smw] 6.0+ +- [Page Forms][pf] 6.0.5+ ## Installation @@ -68,6 +68,6 @@ but can also be executed using `composer phpunit` from the extension base direct [gpl-licence]: https://www.gnu.org/copyleft/gpl.html [smw]: https://github.com/SemanticMediaWiki/SemanticMediaWiki -[sf]: https://www.mediawiki.org/wiki/Extension:Semantic_Forms -[travis]: https://travis-ci.org/SemanticMediaWiki/SemanticSignup +[pf]: https://www.mediawiki.org/wiki/Extension:Page_Forms +[ci]: https://github.com/SemanticMediaWiki/SemanticSignup/actions [composer]: https://getcomposer.org/ diff --git a/SemanticSignup.php b/SemanticSignup.php index c4920f9..33e068f 100644 --- a/SemanticSignup.php +++ b/SemanticSignup.php @@ -10,61 +10,31 @@ * @author Jeroen De Dauw * * @defgroup SES SemanticSignup - */ -if ( !defined( 'MEDIAWIKI' ) ) { - die( 'This file is part of the SemanticSignup extension, it is not a valid entry point.' ); -} - -if ( version_compare( $GLOBALS[ 'wgVersion' ], '1.19', 'lt' ) ) { - die( 'Error: This version of SemanticSignup is only compatible with MediaWiki 1.19 or above. You need to upgrade MediaWiki first.' ); -} - -if ( !defined( 'SF_VERSION' ) || version_compare( SF_VERSION, '2.8', 'lt' ) ) { - die( 'Error: This version of SemanticSignup is only compatible with Semantic Forms 2.8 or above. You need to upgrade Semantic Forms first.' ); -} - -if ( defined( 'SES_VERSION' ) ) { - // Do not initialize more than once. - return 1; -} - -define( 'SES_VERSION', '1.1-alpha' ); - -/** * @codeCoverageIgnore */ -call_user_func( function () { - - // Register extension info - $GLOBALS['wgExtensionCredits']['semantic'][] = array( - 'path' => __DIR__, - 'name' => 'Semantic Signup', - 'version' => SES_VERSION, - 'author' => array( - 'Serg Kutny', - '[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]', - '...' - ), - 'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticSignup', - 'descriptionmsg' => 'ses-desc', - 'license-name' => 'GPL-3.0-or-later' - ); - $GLOBALS['wgMessagesDirs']['semantic-signup'] = __DIR__ . '/i18n'; +class SemanticSignup { - $GLOBALS['wgExtensionMessagesFiles']['semantic-signup'] = __DIR__ . '/i18n/SemanticSignup.i18n.php'; - $GLOBALS['wgExtensionMessagesFiles']['semantic-signup-magic'] = __DIR__ . '/i18n/SemanticSignup.i18n.magic.php'; - $GLOBALS['wgExtensionMessagesFiles']['semantic-signup-alias'] = __DIR__ . '/i18n/SemanticSignup.i18n.aliases.php'; + public static function initExtension( $credits = [] ) { + // See https://phabricator.wikimedia.org/T151136 + define( 'SES_VERSION', isset( $credits['version'] ) ? $credits['version'] : 'UNKNOWN' ); + } - $GLOBALS['wgSpecialPages']['SemanticSignup'] = '\SES\SpecialSemanticSignup'; + public static function onExtensionFunction() { + if ( !defined( 'SMW_VERSION' ) ) { - $GLOBALS['egSemanticSignupSettings'] = array(); - - // Finalize extension setup - $GLOBALS['wgExtensionFunctions'][] = function() { + if ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' ) { + die( "\nThe 'Semantic Signup' extension requires 'Semantic MediaWiki' to be installed and enabled.\n" ); + } else { + die( + 'Error: The Semantic Signup ' . + 'extension requires Semantic MediaWiki to be ' . + 'installed and enabled.
' + ); + } + } $hookRegistry = new HookRegistry(); $hookRegistry->register( $GLOBALS['wgHooks'] ); - }; - -} ); + } +} diff --git a/build b/build new file mode 160000 index 0000000..31d1f9b --- /dev/null +++ b/build @@ -0,0 +1 @@ +Subproject commit 31d1f9b3f9f7b826b9aeb4c098b2a5863cc03b99 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..1db54d9 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,2 @@ +fixes: + - "/var/www/html/extensions/SemanticSignup/::" \ No newline at end of file diff --git a/composer.json b/composer.json index 5c2ad17..98d57a1 100644 --- a/composer.json +++ b/composer.json @@ -23,13 +23,13 @@ "source": "https://github.com/SemanticMediaWiki/SemanticSignup" }, "require": { - "php": ">=5.3.0", - "composer/installers": "1.*,>=1.0.1", - "mediawiki/semantic-media-wiki": "~1.9|~2.0", - "mediawiki/semantic-forms": "~2.8|~3.0" + "php": ">=8.1", + "composer/installers": ">=1.0.1" }, "require-dev": { - "mediawiki/semantic-media-wiki": "@dev" + "mediawiki/minus-x": "1.1.3", + "php-parallel-lint/php-console-highlighter": "1.0.0", + "php-parallel-lint/php-parallel-lint": "1.4.0" }, "extra": { "branch-alias": { @@ -39,15 +39,36 @@ "autoload": { "files" : [ "SemanticSignup.php" - ], - "psr-4": { - "SES\\": "src/" - } + ] }, "config": { - "process-timeout": 0 + "process-timeout": 0, + "allow-plugins": { + "composer/installers": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "scripts":{ - "phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist" + "test": [ + "@analyze", + "@phpunit" + ], + "test-coverage": [ + "@analyze", + "@phpunit-coverage" + ], + "analyze": [ + "@lint", + "@minus-x" + ], + "phpunit": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist", + "phpunit-coverage": "php ${MW_INSTALL_PATH:-../..}/tests/phpunit/phpunit.php -c phpunit.xml.dist --testdox --coverage-text --coverage-html coverage/php --coverage-clover coverage/php/coverage.xml", + "post-test-coverage": [ + "sed -i 's|/var/www/html/extensions/SemanticSignup/||g' coverage/php/coverage.xml", + "find coverage/php -type f -name '*.html' -exec sed -i 's|/var/www/html/extensions/||g' {} +" + ], + "integration": "composer phpunit -- --testsuite=semantic-result-formats-integration", + "lint": "parallel-lint . --exclude vendor --exclude node_modules --exclude extensions", + "minus-x": "minus-x check ." } } diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..5f0ad94 --- /dev/null +++ b/extension.json @@ -0,0 +1,50 @@ +{ + "name": "SemanticSignup", + "version": "1.1-alpha", + "author": [ + "Serg Kutny", + "[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]", + "..." + ], + "url": "https://www.mediawiki.org/wiki/Extension:SemanticSignup", + "descriptionmsg": "ses-desc", + "license-name": "GPL-3.0-or-later", + "type": "semantic", + "requires": { + "MediaWiki": ">= 1.43", + "extensions": { + "SemanticMediaWiki": ">= 6.0" + } + }, + "MessagesDirs": { + "SemanticSignup": [ + "i18n" + ] + }, + "callback": "SemanticSignup::initExtension", + "ExtensionFunctions": [ + "SemanticSignup::onExtensionFunction" + ], + "ExtensionMessagesFiles": { + "SemanticSignupAlias": "i18n/SemanticSignup.i18n.aliases.php", + "SemanticSignupMagic": "i18n/SemanticSignup.i18n.magic.php" + }, + "AutoloadNamespaces": { + "SES\\": "src/" + }, + "TestAutoloadNamespaces": { + "SES\\Tests\\": "tests/phpunit/" + }, + "SpecialPages": { + "SemanticSignup": "SES\\SpecialSemanticSignup" + }, + "config_prefix": "eg", + "config": { + "SemanticSignupSettings": { + "value": [], + "description": "..." + } + }, + "load_composer_autoloader": true, + "manifest_version": 2 +} diff --git a/i18n/SemanticSignup.i18n.php b/i18n/SemanticSignup.i18n.php deleted file mode 100644 index 0931bae..0000000 --- a/i18n/SemanticSignup.i18n.php +++ /dev/null @@ -1,35 +0,0 @@ -form ); - $form_definition = $form->getContent(); + $form_definition = $form->fetchRevisionRecord(); list ( $form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name ) = $this->formPrinter->formHTML( $form_definition, $this->submitState, false ); diff --git a/src/HookRegistry.php b/src/HookRegistry.php index effb910..37950b9 100644 --- a/src/HookRegistry.php +++ b/src/HookRegistry.php @@ -2,8 +2,8 @@ namespace SES; +use MediaWiki\Title\Title; use Parser; -use Title; use SpecialPage; /** diff --git a/src/RedirectFormFinder.php b/src/RedirectFormFinder.php index 2d1d433..b02809c 100644 --- a/src/RedirectFormFinder.php +++ b/src/RedirectFormFinder.php @@ -2,6 +2,7 @@ namespace SES; +use MediaWiki\MediaWikiServices; use OutputPage; use SpecialPage; @@ -42,7 +43,14 @@ public function redirectToUrl( $output ) { $url = htmlspecialchars( SpecialPage::getTitleFor( 'SemanticSignup' )->getFullURL() ); - wfRunHooks( 'SemanticSignupBeforeRedirect', array( &$url ) ); + MediaWikiServices::getInstance() + ->getHookContainer() + ->run( + 'SemanticSignupBeforeRedirect', + [ + &$url + ] + ); $output->redirect( $url ); diff --git a/src/SignupFactory.php b/src/SignupFactory.php index b89085a..67b656a 100644 --- a/src/SignupFactory.php +++ b/src/SignupFactory.php @@ -2,7 +2,7 @@ namespace SES; -use Title; +use MediaWiki\Title\Title; /** * @license GNU GPL v2+ @@ -21,12 +21,12 @@ public function newFormPrinterHandler() { $form = Title::newFromText( Settings::get( 'formName' ), - SF_NS_FORM + \PF_NS_FORM ); return new FormPrinterHandler( $form, - $GLOBALS['sfgFormPrinter'] + $GLOBALS['wgPageFormsFormPrinter'] ); } diff --git a/src/SignupFieldsParserFunction.php b/src/SignupFieldsParserFunction.php index 7716a9b..f5253ae 100644 --- a/src/SignupFieldsParserFunction.php +++ b/src/SignupFieldsParserFunction.php @@ -55,7 +55,7 @@ private function createUserFieldsTemplateFields() { $this->userFieldsCreateTemplate->set( 'link', '' ); // TODO $this->userFieldsCreateTemplate->set( 'email', '' ); // TODO - $this->userFieldsCreateTemplate->set( 'createemail', $wgEnableEmail && $wgUser->isLoggedIn() ); + $this->userFieldsCreateTemplate->set( 'createemail', $wgEnableEmail && $wgUser->isRegistered() ); $this->userFieldsCreateTemplate->set( 'userealname', $allowRealName ); $this->userFieldsCreateTemplate->set( 'useemail', $wgEnableEmail ); $this->userFieldsCreateTemplate->set( 'emailrequired', $wgEmailConfirmToEdit ); diff --git a/src/SpecialSemanticSignup.php b/src/SpecialSemanticSignup.php index af700bd..1109a34 100644 --- a/src/SpecialSemanticSignup.php +++ b/src/SpecialSemanticSignup.php @@ -2,13 +2,13 @@ namespace SES; +use MediaWiki\Title\Title; +use MediaWiki\User\User; use SpecialPage; use Exception; use SiteStatsUpdate; use Sanitizer; -use Title; use Article; -use User; /** * Special page to replace SpecialUserLogin/signup with an equivalent diff --git a/src/UserAccountDataChecker.php b/src/UserAccountDataChecker.php index eddd4c2..092c48c 100644 --- a/src/UserAccountDataChecker.php +++ b/src/UserAccountDataChecker.php @@ -2,9 +2,9 @@ namespace SES; -use User; -use Sanitizer; use Exception; +use MediaWiki\User\User; +use Sanitizer; /** * @license GNU GPL v3+ diff --git a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php index fc25d72..52ab537 100644 --- a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php +++ b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php @@ -2,6 +2,7 @@ namespace SES\Tests\Integration; +use PHPUnit\Framework\TestCase; use SMW\Tests\Utils\UtilityFactory; /** @@ -13,7 +14,7 @@ * * @author mwjames */ -class I18nJsonFileIntegrityTest extends \PHPUnit_Framework_TestCase { +class I18nJsonFileIntegrityTest extends TestCase { /** * @dataProvider i18nFileProvider @@ -22,23 +23,21 @@ public function testI18NJsonDecodeEncode( $file ) { $jsonFileReader = UtilityFactory::getInstance()->newJsonFileReader( $file ); - $this->assertInternalType( - 'integer', + $this->assertIsInt( $jsonFileReader->getModificationTime() ); - $this->assertInternalType( - 'array', + $this->assertIsArray( $jsonFileReader->read() ); } public function i18nFileProvider() { - $provider = array(); - $location = $GLOBALS['wgMessagesDirs']['semantic-signup']; + $provider = []; + $location = $GLOBALS['wgMessagesDirs']['SemanticSignup']; - $bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location ); + $bulkFileProvider = UtilityFactory::getInstance()->newBulkFileProvider( $location[0] ); $bulkFileProvider->searchByFileExtension( 'json' ); foreach ( $bulkFileProvider->getFiles() as $file ) { diff --git a/tests/phpunit/Unit/DataCheckerTest.php b/tests/phpunit/Unit/DataCheckerTest.php index fce7c62..1b1f39f 100644 --- a/tests/phpunit/Unit/DataCheckerTest.php +++ b/tests/phpunit/Unit/DataCheckerTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\DataChecker; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class DataCheckerTest extends \PHPUnit_Framework_TestCase { +class DataCheckerTest extends TestCase { public function testCanConstruct() { diff --git a/tests/phpunit/Unit/FormPrinterHandlerTest.php b/tests/phpunit/Unit/FormPrinterHandlerTest.php index 559aa7a..d8579a4 100644 --- a/tests/phpunit/Unit/FormPrinterHandlerTest.php +++ b/tests/phpunit/Unit/FormPrinterHandlerTest.php @@ -2,8 +2,9 @@ namespace SES\Tests; +use MediaWiki\Title\Title; +use PHPUnit\Framework\TestCase; use SES\FormPrinterHandler; -use Title; /** * @covers \SES\FormPrinterHandler @@ -15,7 +16,7 @@ * * @author mwjames */ -class FormPrinterHandlerTest extends \PHPUnit_Framework_TestCase { +class FormPrinterHandlerTest extends TestCase { public function testCanConstruct() { @@ -33,7 +34,7 @@ public function testCanUseForm() { $instance->canUseForm() ); - $title = $this->getMockBuilder( '\Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); @@ -41,6 +42,10 @@ public function testCanUseForm() { ->method( 'exists' ) ->will( $this->returnValue( true ) ); + $title->expects( $this->any() ) + ->method( 'canExist' ) + ->will( $this->returnValue( true ) ); + $instance = new FormPrinterHandler( $title ); $this->assertTrue( @@ -51,7 +56,7 @@ public function testCanUseForm() { public function testGetFormText() { - $title = $this->getMockBuilder( '\Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); @@ -59,13 +64,17 @@ public function testGetFormText() { ->method( 'exists' ) ->will( $this->returnValue( true ) ); + $title->expects( $this->any() ) + ->method( 'canExist' ) + ->will( $this->returnValue( true ) ); + $instance = new FormPrinterHandler( $title ); $this->assertEmpty( $instance->getFormText() ); - $formPrinter = $this->getMockBuilder( '\SFFormPrinter' ) + $formPrinter = $this->getMockBuilder( '\PFFormPrinter' ) ->disableOriginalConstructor() ->getMock(); @@ -86,7 +95,7 @@ public function testGetFormText() { public function testGetTemplateText() { - $title = $this->getMockBuilder( '\Title' ) + $title = $this->getMockBuilder( Title::class ) ->disableOriginalConstructor() ->getMock(); @@ -94,13 +103,17 @@ public function testGetTemplateText() { ->method( 'exists' ) ->will( $this->returnValue( true ) ); + $title->expects( $this->any() ) + ->method( 'canExist' ) + ->will( $this->returnValue( true ) ); + $instance = new FormPrinterHandler( $title ); $this->assertEmpty( $instance->getTemplateText() ); - $formPrinter = $this->getMockBuilder( '\SFFormPrinter' ) + $formPrinter = $this->getMockBuilder( '\PFFormPrinter' ) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/phpunit/Unit/HookRegistryTest.php b/tests/phpunit/Unit/HookRegistryTest.php index b4f4e5f..e48c0cf 100644 --- a/tests/phpunit/Unit/HookRegistryTest.php +++ b/tests/phpunit/Unit/HookRegistryTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\HookRegistry; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class HookRegistryTest extends \PHPUnit_Framework_TestCase { +class HookRegistryTest extends TestCase { public function testCanConstruct() { @@ -56,8 +57,7 @@ public function testRegister() { private function assertHookIsExcutable( $wgHooks, $hookName, $arguments ) { foreach ( $wgHooks[ $hookName ] as $hook ) { - $this->assertInternalType( - 'boolean', + $this->assertIsBool( call_user_func_array( $hook, $arguments ) ); } diff --git a/tests/phpunit/Unit/ParserFunctionFactoryTest.php b/tests/phpunit/Unit/ParserFunctionFactoryTest.php index 0ba7678..1d49b3a 100644 --- a/tests/phpunit/Unit/ParserFunctionFactoryTest.php +++ b/tests/phpunit/Unit/ParserFunctionFactoryTest.php @@ -2,11 +2,10 @@ namespace SES\Tests; -use SES\ParserFunctionFactory; - -use Title; +use PHPUnit\Framework\TestCase; use Parser; use ParserOptions; +use SES\ParserFunctionFactory; /** * @covers \SES\ParserFunctionFactory @@ -18,7 +17,7 @@ * * @author mwjames */ -class ParserFunctionFactoryTest extends \PHPUnit_Framework_TestCase { +class ParserFunctionFactoryTest extends TestCase { public function testCanConstruct() { diff --git a/tests/phpunit/Unit/RedirectFormFinderTest.php b/tests/phpunit/Unit/RedirectFormFinderTest.php index 40d5d23..024668f 100644 --- a/tests/phpunit/Unit/RedirectFormFinderTest.php +++ b/tests/phpunit/Unit/RedirectFormFinderTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\RedirectFormFinder; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class RedirectFormFinderTest extends \PHPUnit_Framework_TestCase { +class RedirectFormFinderTest extends TestCase { public function testCanConstruct() { diff --git a/tests/phpunit/Unit/SettingsTest.php b/tests/phpunit/Unit/SettingsTest.php index 6f59eef..4152f15 100644 --- a/tests/phpunit/Unit/SettingsTest.php +++ b/tests/phpunit/Unit/SettingsTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\Settings; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class SettingsTest extends \PHPUnit_Framework_TestCase { +class SettingsTest extends TestCase { public function testCanConstruct() { @@ -28,8 +29,7 @@ public function testGetSettings() { $instance = new Settings(); - $this->assertInternalType( - 'array', + $this->assertIsArray( $instance->getSettings() ); } diff --git a/tests/phpunit/Unit/SignupFactoryTest.php b/tests/phpunit/Unit/SignupFactoryTest.php index b8ceada..8b6d64a 100644 --- a/tests/phpunit/Unit/SignupFactoryTest.php +++ b/tests/phpunit/Unit/SignupFactoryTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\SignupFactory; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class SignupFactoryTest extends \PHPUnit_Framework_TestCase { +class SignupFactoryTest extends TestCase { public function testCanConstruct() { diff --git a/tests/phpunit/Unit/SignupFieldsParserFunctionTest.php b/tests/phpunit/Unit/SignupFieldsParserFunctionTest.php index 8714c91..86280af 100644 --- a/tests/phpunit/Unit/SignupFieldsParserFunctionTest.php +++ b/tests/phpunit/Unit/SignupFieldsParserFunctionTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\SignupFieldsParserFunction; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class SignupFieldsParserFunctionTest extends \PHPUnit_Framework_TestCase { +class SignupFieldsParserFunctionTest extends TestCase { public function testCanConstruct() { @@ -36,8 +37,7 @@ public function testExecute() { $instance = new SignupFieldsParserFunction( $userFieldsCreateTemplate ); - $this->assertInternalType( - 'array', + $this->assertIsArray( $instance->parse( array() ) ); } diff --git a/tests/phpunit/Unit/SpecialSemanticSignupTest.php b/tests/phpunit/Unit/SpecialSemanticSignupTest.php index 6e52c22..c391f76 100644 --- a/tests/phpunit/Unit/SpecialSemanticSignupTest.php +++ b/tests/phpunit/Unit/SpecialSemanticSignupTest.php @@ -2,6 +2,9 @@ namespace SES\Tests; +use FauxRequest; +use MediaWiki\SpecialPage\SpecialPageFactory; +use PHPUnit\Framework\TestCase; use SES\SpecialSemanticSignup; /** @@ -14,15 +17,14 @@ * * @author mwjames */ -class SpecialSemanticSignupTest extends \PHPUnit_Framework_TestCase { +class SpecialSemanticSignupTest extends TestCase { public function testCanConstruct() { - $request = new \FauxRequest( array(), true ); - $specialPage = \SpecialPageFactory::getPage( 'SemanticSignup' ); + $request = new FauxRequest( array(), true ); + $specialPage = SpecialPageFactory::getPage( 'SemanticSignup' ); - // Deprecated: Use of SpecialPage::getTitle was deprecated in MediaWiki 1.23 - $title = method_exists( $specialPage, 'getPageTitle') ? $specialPage->getPageTitle() : $specialPage->getTitle(); + $title = $specialPage->getPageTitle(); $context = \RequestContext::newExtraneousContext( $title ); $context->setRequest( $request ); diff --git a/tests/phpunit/Unit/UserAccountDataCheckerTest.php b/tests/phpunit/Unit/UserAccountDataCheckerTest.php index 1e13ff9..55cadb6 100644 --- a/tests/phpunit/Unit/UserAccountDataCheckerTest.php +++ b/tests/phpunit/Unit/UserAccountDataCheckerTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\UserAccountDataChecker; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class UserAccountDataCheckerTest extends \PHPUnit_Framework_TestCase { +class UserAccountDataCheckerTest extends TestCase { public function testCanConstruct() { diff --git a/tests/phpunit/Unit/UserFieldsCreateTemplateTest.php b/tests/phpunit/Unit/UserFieldsCreateTemplateTest.php index 295c4ee..da77c6e 100644 --- a/tests/phpunit/Unit/UserFieldsCreateTemplateTest.php +++ b/tests/phpunit/Unit/UserFieldsCreateTemplateTest.php @@ -2,6 +2,7 @@ namespace SES\Tests; +use PHPUnit\Framework\TestCase; use SES\UserFieldsCreateTemplate; /** @@ -14,7 +15,7 @@ * * @author mwjames */ -class UserFieldsCreateTemplateTest extends \PHPUnit_Framework_TestCase { +class UserFieldsCreateTemplateTest extends TestCase { public function testCanConstruct() { diff --git a/tests/travis/install-mediawiki.sh b/tests/travis/install-mediawiki.sh deleted file mode 100644 index 3e5caad..0000000 --- a/tests/travis/install-mediawiki.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -ex - -cd .. - -## Use sha (master@5cc1f1d) to download a particular commit to avoid breakages -## introduced by MediaWiki core -if [[ "$MW" == *@* ]] -then - arrMw=(${MW//@/ }) - MW=${arrMw[0]} - SOURCE=${arrMw[1]} -else - MW=$MW - SOURCE=$MW -fi - -wget https://github.com/wikimedia/mediawiki/archive/$SOURCE.tar.gz -O $MW.tar.gz - -tar -zxf $MW.tar.gz -mv mediawiki-* mw - -cd mw - -## MW 1.25 requires Psr\Logger -if [ -f composer.json ] -then - composer install --prefer-source -fi - -if [ "$DB" == "postgres" ] -then - # See #458 - sudo /etc/init.d/postgresql stop - sudo /etc/init.d/postgresql start - - psql -c 'create database its_a_mw;' -U postgres - php maintenance/install.php --dbtype $DB --dbuser postgres --dbname its_a_mw --pass AdminPassword TravisWiki admin --scriptpath /TravisWiki -else - mysql -e 'create database its_a_mw;' - php maintenance/install.php --dbtype $DB --dbuser root --dbname its_a_mw --dbpath $(pwd) --pass AdminPassword TravisWiki admin --scriptpath /TravisWiki -fi diff --git a/tests/travis/install-semantic-signup.sh b/tests/travis/install-semantic-signup.sh deleted file mode 100644 index 69ec00e..0000000 --- a/tests/travis/install-semantic-signup.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -set -ex - -BASE_PATH=$(pwd) -MW_INSTALL_PATH=$BASE_PATH/../mw - -# Run Composer installation from the MW root directory -function installToMediaWikiRoot { - echo -e "Running MW root composer install build on $TRAVIS_BRANCH \n" - - cd $MW_INSTALL_PATH - - if [ "$PHPUNIT" != "" ] - then - composer require 'phpunit/phpunit='$PHPUNIT --prefer-source --update-with-dependencies - else - composer require 'phpunit/phpunit=3.7.*' --prefer-source --update-with-dependencies - fi - - if [ "$SES" != "" ] - then - composer require 'mediawiki/semantic-signup='$SES --prefer-source --update-with-dependencies - else - composer init --stability dev - composer require mediawiki/semantic-signup "dev-master" --prefer-source --dev --update-with-dependencies - - cd extensions - cd SemanticSignup - - # Pull request number, "false" if it's not a pull request - # After the install via composer an additional get fetch is carried out to - # update th repository to make sure that the latests code changes are - # deployed for testing - if [ "$TRAVIS_PULL_REQUEST" != "false" ] - then - git fetch origin +refs/pull/"$TRAVIS_PULL_REQUEST"/merge: - git checkout -qf FETCH_HEAD - else - git fetch origin "$TRAVIS_BRANCH" - git checkout -qf FETCH_HEAD - fi - - cd ../.. - fi - - # Rebuild the class map for added classes during git fetch - composer dump-autoload -} - -function updateConfiguration { - - cd $MW_INSTALL_PATH - - # Site language - if [ "$SITELANG" != "" ] - then - echo '$wgLanguageCode = "'$SITELANG'";' >> LocalSettings.php - fi - - echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php - echo 'ini_set("display_errors", 1);' >> LocalSettings.php - echo '$wgShowExceptionDetails = true;' >> LocalSettings.php - echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php - echo "putenv( 'MW_INSTALL_PATH=$(pwd)' );" >> LocalSettings.php - - php maintenance/update.php --quick -} - -installToMediaWikiRoot -updateConfiguration diff --git a/tests/travis/run-tests.sh b/tests/travis/run-tests.sh deleted file mode 100644 index 48519e5..0000000 --- a/tests/travis/run-tests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/bash -set -ex - -BASE_PATH=$(pwd) -MW_INSTALL_PATH=$BASE_PATH/../mw - -cd $MW_INSTALL_PATH/extensions/SemanticSignup - -if [ "$TYPE" == "coverage" ] -then - composer phpunit -- --coverage-clover $BASE_PATH/build/coverage.clover -else - composer phpunit -fi diff --git a/tests/travis/upload-coverage-report.sh b/tests/travis/upload-coverage-report.sh deleted file mode 100644 index aff95cf..0000000 --- a/tests/travis/upload-coverage-report.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash -set -ex - -BASE_PATH=$(pwd) - -if [ "$TYPE" == "coverage" ] -then - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover $BASE_PATH/build/coverage.clover -fi \ No newline at end of file