diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fe1ea1..db5e9fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,34 +13,27 @@ jobs: strategy: matrix: include: - - mw: 'REL1_39' - php: 8.0 - type: coverage - experimental: false - - mw: 'REL1_39' - php: 8.1 - type: normal - experimental: false - - mw: 'REL1_40' - php: 8.1 - type: normal - experimental: false - - mw: 'REL1_41' + - mw: 'REL1_43' php: 8.1 + # TODO: Scrutinzer Ocular overage disabled due to https://github.com/scrutinizer-ci/ocular/issues/51 type: normal - experimental: false - - mw: 'REL1_42' + experimental: true + - mw: 'REL1_44' php: 8.2 type: normal experimental: false - - mw: 'REL1_43' + - mw: 'REL1_45' php: 8.3 type: normal - experimental: true + experimental: false - mw: 'master' php: 8.4 type: normal experimental: true + - mw: 'master' + php: 8.5 + type: normal + experimental: true runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 871b49f..0a9a12a 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -14,8 +14,9 @@ tools: php_loc: true php_analyzer: true sensiolabs_security_checker: true - external_code_coverage: - timeout: '1200' # timeout in seconds + # TODO: Scrutinzer Ocular overage disabled due to https://github.com/scrutinizer-ci/ocular/issues/51 + # external_code_coverage: + # timeout: '1200' # timeout in seconds checks: php: diff --git a/README.md b/README.md index b4683f7..1c259d6 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Bootstrap Components is a [MediaWiki] extension that aims to provide editors with easy access to certain components introduced by -[Twitter Bootstrap 4][Bootstrap]. +[Twitter Bootstrap 5][Bootstrap]. Depending on your configuration, editors can utilize several _tag extensions_ and _parser functions_ inside wiki code to place certain @@ -16,8 +16,8 @@ configuration it can add a new [gallery][Gallery] mode, and replace normal [image rendering][Image] with an image modal. ## Requirements -* PHP 8.0 or later -* MediaWiki 1.39 or later +* PHP 8.1 or later +* MediaWiki 1.43 or later ## Documentation - [Installation and configuration](docs/installation-configuration.md) @@ -31,8 +31,9 @@ configuration it can add a new [gallery][Gallery] mode, and replace normal Please also see the [known issues][known-issues] section. -There is also a [migration guide](docs/migration-guide.md) for users switching -from bootstrap3 (BootstrapComponents ~1.2) to bootstrap4 (BootstrapComponents ~4.0). +There is also a [migration guide](docs/migration-guide.md) for users switching between versions: +- Bootstrap 3 → Bootstrap 4: BootstrapComponents ~1.2 → ~4.0 +- Bootstrap 4 → Bootstrap 5: BootstrapComponents ~5.x → ~6.0 ## Contact For bug reports and feature requests, please see if it is already reported on diff --git a/composer.json b/composer.json index 3691d76..1fce816 100644 --- a/composer.json +++ b/composer.json @@ -25,15 +25,15 @@ "source": "https://github.com/oetterer/BootstrapComponents" }, "require": { - "php": ">=8.0", + "php": ">=8.1", "composer/installers": "^2|^1.0.1", - "mediawiki/bootstrap": "^5.0" + "mediawiki/bootstrap": "6.x-dev" }, "require-dev": { "mediawiki/mediawiki-codesniffer": "46.0.0", - "mediawiki/mediawiki-phan-config": "0.15.1", + "mediawiki/mediawiki-phan-config": "0.15.1", "phpmd/phpmd": "~2.1", - "php": ">=8.0" + "php": ">=8.1" }, "suggest": { "mediawiki/scribunto": "Framework for embedding scripting languages into MediaWiki pages" @@ -58,5 +58,10 @@ "composer phpunit", "composer cs" ] + }, + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } } } diff --git a/docs/migration-guide.md b/docs/migration-guide.md index 8a84850..526663a 100644 --- a/docs/migration-guide.md +++ b/docs/migration-guide.md @@ -1,7 +1,97 @@ ## Migration Guide +### Migrating from Bootstrap 4 (BootstrapComponents 5.x) to Bootstrap 5 (BootstrapComponents 6.0) + +BootstrapComponents 6.0 upgrades the underlying Bootstrap framework from version 4 to version 5.3. This guide helps you understand the changes and migrate your wiki. + +#### System Requirements +- **MediaWiki:** 1.43 or later (upgraded from 1.39) +- **PHP:** 8.1 or later (upgraded from 8.0) +- **Bootstrap Extension:** mediawiki/bootstrap 6.x-dev from [ProfessionalWiki/Bootstrap](https://github.com/ProfessionalWiki/Bootstrap) + +#### User Impact +**Good News:** Most existing wiki markup using BootstrapComponents should continue to work without any changes! The extension handles most Bootstrap 5 migrations internally. + +#### Component Changes + +##### Jumbotron +The Jumbotron component still works but now uses Bootstrap 5 utility classes instead of the removed `.jumbotron` class. The visual appearance should be similar but may have minor differences. Consider: +- Using utility classes directly: `
` +- Or continue using `` tag which is now implemented using these utilities +- Reference: https://getbootstrap.com/docs/5.3/examples/jumbotron/ + +##### Button Colors +The `color="default"` attribute is automatically mapped to `color="secondary"` in Bootstrap 5. If you prefer different colors: +- Use `color="light"` for light gray buttons +- Use `color="secondary"` explicitly for the standard secondary color + +##### Badge Pill +If you're using custom CSS targeting `.badge-pill`, update to `.rounded-pill`: +```css +/* Old */ +.badge-pill { ... } + +/* New */ +.rounded-pill { ... } +``` + +##### Alert and Modal Close Buttons +Close buttons now use Bootstrap 5's `.btn-close` class. If you have custom CSS targeting `.close`: +```css +/* Old */ +.close { ... } + +/* New */ +.btn-close { ... } +``` + +#### JavaScript Changes +Bootstrap 5 removed jQuery dependency. If you have custom JavaScript interacting with Bootstrap components: + +**Old (Bootstrap 4 + jQuery):** +```javascript +$('.carousel').carousel(); +$('[data-toggle="tooltip"]').tooltip(); +``` + +**New (Bootstrap 5 vanilla JS):** +```javascript +document.querySelectorAll('.carousel').forEach(el => { + new bootstrap.Carousel(el); +}); +document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(el => { + new bootstrap.Tooltip(el); +}); +``` + +#### Data Attributes +If you're using custom HTML with Bootstrap data attributes, update to the `data-bs-*` prefix: +- `data-toggle` → `data-bs-toggle` +- `data-target` → `data-bs-target` +- `data-dismiss` → `data-bs-dismiss` +- `data-slide` → `data-bs-slide` +- `data-parent` → `data-bs-parent` +- `data-content` → `data-bs-content` +- `data-placement` → `data-bs-placement` +- `data-trigger` → `data-bs-trigger` + +#### Testing Your Upgrade +After upgrading: +1. Test all pages using BootstrapComponents +2. Verify modals, tooltips, popovers, and carousels work correctly +3. Check custom CSS for compatibility +4. Test any custom JavaScript interacting with Bootstrap +5. Verify with different MediaWiki skins (Vector, Vector-2022) + +#### Rollback +If you encounter issues, you can rollback to BootstrapComponents 5.x which uses Bootstrap 4. + +--- + +### Migrating from Bootstrap 3 (BootstrapComponents 1.x) to Bootstrap 4 (BootstrapComponents 4.x-5.x) + There have been some changes between versions ~1.0 and ~4.0. Foremost is that -the new BootstrapComponents utilizes Twitter Bootstrap4. Therefore, it mirrors +the new BootstrapComponents utilizes Twitter Bootstrap 4. Therefore, it mirrors changes made by Bootstrap. Also, extension loading must now be done manually in your LocalSettings, no diff --git a/docs/release-notes.md b/docs/release-notes.md index 690fb52..e589f03 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,39 @@ ## Release Notes +### BootstrapComponents 6.0.0 + +Released on _TBD_ + +**BREAKING CHANGES:** +* Requires MediaWiki 1.43 or later (upgraded from 1.39) +* Requires PHP 8.1 or later (upgraded from 8.0) +* Upgraded from Bootstrap 4 to Bootstrap 5.3 +* Changed Bootstrap dependency from `mediawiki/bootstrap ^5.0` to `mediawiki/bootstrap 6.x-dev` (ProfessionalWiki) + +**Bootstrap 5 Migration Changes:** +* All data attributes updated to Bootstrap 5 format with `data-bs-*` prefix: + - `data-toggle` → `data-bs-toggle` + - `data-target` → `data-bs-target` + - `data-dismiss` → `data-bs-dismiss` + - `data-slide` → `data-bs-slide` + - `data-parent` → `data-bs-parent` + - `data-content` → `data-bs-content` + - `data-placement` → `data-bs-placement` + - `data-trigger` → `data-bs-trigger` +* JavaScript modules migrated from jQuery to vanilla JavaScript (Bootstrap 5 requirement) +* Badge component: `badge-pill` class changed to `rounded-pill` +* Button component: `btn-default` automatically mapped to `btn-secondary` +* Alert and Modal close buttons: Migrated from `.close` class with `×` character to `.btn-close` class +* Jumbotron component: Recreated using Bootstrap 5 utility classes (`p-5 mb-4 bg-body-tertiary rounded-3`) +* All CSS fixes reviewed and updated for Bootstrap 5 compatibility + +**User Impact:** +* Most existing wiki markup using BootstrapComponents should continue to work without changes +* JavaScript initialization now uses Bootstrap 5 native API +* Custom CSS may need review if it targets Bootstrap 4-specific classes + +See [migration guide](migration-guide.md) for detailed upgrade instructions. + ### BootstrapComponents 5.3.0 Released on _not yet_ diff --git a/extension.json b/extension.json index 5e5851a..80eb3e8 100644 --- a/extension.json +++ b/extension.json @@ -1,13 +1,13 @@ { "name": "BootstrapComponents", - "version": "5.2.1", + "version": "6.0.0-dev", "author": [ "Tobias Oetterer" ], "url": "https://www.mediawiki.org/wiki/Extension:BootstrapComponents", "descriptionmsg": "bootstrap-components-desc", "license-name": "GPL-3.0-or-later", "type": "parserhook", "requires": { - "MediaWiki": ">= 1.39.0" + "MediaWiki": ">= 1.43.0" }, "ConfigRegistry": { "BootstrapComponents": "GlobalVarConfig::newInstance" diff --git a/modules/ext.bootstrapComponents.button.fix.css b/modules/ext.bootstrapComponents.button.fix.css index d5e78ac..2b537f1 100644 --- a/modules/ext.bootstrapComponents.button.fix.css +++ b/modules/ext.bootstrapComponents.button.fix.css @@ -25,12 +25,8 @@ /* * a href prioritizes the mw link color. overwrite this here to a more suitable one + * Bootstrap 5: btn-default removed */ -a.btn-default, -a.btn-default:link, -a.btn-default:visited, -a.btn-default:active, -a.btn-default:hover, a.btn-light, a.btn-light:link, a.btn-light:visited, @@ -79,19 +75,15 @@ a.btn-dark:hover { /** * outline link colors have to be defined separately + * Bootstrap 5: btn-outline-default removed */ -a.btn-outline-default, -a.btn-outline-default:link, -a.btn-outline-default:visited, -a.btn-outline-default:active, a.btn-outline-light, a.btn-outline-light:link, a.btn-outline-light:visited, a.btn-outline-light:active { color: var(--white); } -a.btn-outline-default:hover, a.btn-outline-light:hover { color: #212529; } diff --git a/modules/ext.bootstrapComponents.carousel.js b/modules/ext.bootstrapComponents.carousel.js index 941f604..eef7783 100644 --- a/modules/ext.bootstrapComponents.carousel.js +++ b/modules/ext.bootstrapComponents.carousel.js @@ -1,5 +1,7 @@ /** - * Contains javascript code executed when tooltips are used. + * Contains javascript code executed when carousels are used. + * + * Bootstrap 5 migration: Converted from jQuery to vanilla JavaScript. * * @copyright (C) 2018, Tobias Oetterer, Paderborn University * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 (or later) @@ -23,6 +25,24 @@ * @author Tobias Oetterer */ -$(function () { - $('.carousel').carousel(); -}); +( function () { + 'use strict'; + + // Wait for DOM to be ready + if ( document.readyState === 'loading' ) { + document.addEventListener( 'DOMContentLoaded', initCarousels ); + } else { + initCarousels(); + } + + function initCarousels() { + // Bootstrap 5 automatically initializes carousels with data-bs-ride="carousel" + // Manual initialization for additional control + var carouselElements = document.querySelectorAll( '.carousel' ); + carouselElements.forEach( function ( element ) { + if ( typeof bootstrap !== 'undefined' && bootstrap.Carousel ) { + new bootstrap.Carousel( element ); + } + } ); + } +}() ); diff --git a/modules/ext.bootstrapComponents.popover.js b/modules/ext.bootstrapComponents.popover.js index 82a03ea..11f5f42 100644 --- a/modules/ext.bootstrapComponents.popover.js +++ b/modules/ext.bootstrapComponents.popover.js @@ -1,6 +1,8 @@ /** * Contains javascript code executed when popovers are used. * + * Bootstrap 5 migration: Converted from jQuery to vanilla JavaScript. + * * @copyright (C) 2018, Tobias Oetterer, Paderborn University * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 (or later) * @@ -22,11 +24,26 @@ * @ingroup BootstrapComponents * @author Tobias Oetterer */ -$( function() { - $(document).ready(function(){ - $('[data-toggle="popover"]').popover({ - html: true - }); - }); - } -); + +( function () { + 'use strict'; + + // Wait for DOM to be ready + if ( document.readyState === 'loading' ) { + document.addEventListener( 'DOMContentLoaded', initPopovers ); + } else { + initPopovers(); + } + + function initPopovers() { + // Initialize all popovers with HTML enabled (Bootstrap 5 vanilla JS API) + var popoverTriggerList = document.querySelectorAll( '[data-bs-toggle="popover"]' ); + popoverTriggerList.forEach( function ( popoverTriggerEl ) { + if ( typeof bootstrap !== 'undefined' && bootstrap.Popover ) { + new bootstrap.Popover( popoverTriggerEl, { + html: true + } ); + } + } ); + } +}() ); diff --git a/modules/ext.bootstrapComponents.tooltip.js b/modules/ext.bootstrapComponents.tooltip.js index 575e021..0610aab 100644 --- a/modules/ext.bootstrapComponents.tooltip.js +++ b/modules/ext.bootstrapComponents.tooltip.js @@ -1,6 +1,8 @@ /** * Contains javascript code executed when tooltips are used. * + * Bootstrap 5 migration: Converted from jQuery to vanilla JavaScript. + * * @copyright (C) 2018, Tobias Oetterer, Paderborn University * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 (or later) * @@ -23,9 +25,23 @@ * @author Tobias Oetterer */ -$( function() { - $(document).ready(function(){ - $('[data-toggle="tooltip"]').tooltip(); - }); - } -); \ No newline at end of file +( function () { + 'use strict'; + + // Wait for DOM to be ready + if ( document.readyState === 'loading' ) { + document.addEventListener( 'DOMContentLoading', initTooltips ); + } else { + initTooltips(); + } + + function initTooltips() { + // Initialize all tooltips with Bootstrap 5 vanilla JS API + var tooltipTriggerList = document.querySelectorAll( '[data-bs-toggle="tooltip"]' ); + tooltipTriggerList.forEach( function ( tooltipTriggerEl ) { + if ( typeof bootstrap !== 'undefined' && bootstrap.Tooltip ) { + new bootstrap.Tooltip( tooltipTriggerEl ); + } + } ); + } +}() ); \ No newline at end of file diff --git a/src/AbstractComponent.php b/src/AbstractComponent.php index e3ae555..7700bc2 100644 --- a/src/AbstractComponent.php +++ b/src/AbstractComponent.php @@ -26,7 +26,7 @@ namespace MediaWiki\Extension\BootstrapComponents; -use \MWException; +use MWException; /** * Class AbstractComponent diff --git a/src/BootstrapComponents.php b/src/BootstrapComponents.php index 628c5d8..6595ae2 100644 --- a/src/BootstrapComponents.php +++ b/src/BootstrapComponents.php @@ -43,7 +43,6 @@ namespace MediaWiki\Extension\BootstrapComponents; -use ConfigException; use Exception; use MWException; diff --git a/src/CarouselGallery.php b/src/CarouselGallery.php index dd05855..764b7b6 100644 --- a/src/CarouselGallery.php +++ b/src/CarouselGallery.php @@ -26,10 +26,10 @@ namespace MediaWiki\Extension\BootstrapComponents; -use MediaWiki\Extension\BootstrapComponents\Components\Carousel; use ImageGalleryBase; +use MediaWiki\Extension\BootstrapComponents\Components\Carousel; use MediaWiki\MediaWikiServices; -use Title; +use MediaWiki\Title\Title; /** * Class CarouselGallery diff --git a/src/ComponentLibrary.php b/src/ComponentLibrary.php index 382326c..c496968 100644 --- a/src/ComponentLibrary.php +++ b/src/ComponentLibrary.php @@ -26,8 +26,7 @@ namespace MediaWiki\Extension\BootstrapComponents; -use MediaWiki\MediaWikiServices; -use \MWException; +use MWException; /** * Class ComponentLibrary diff --git a/src/Components/Accordion.php b/src/Components/Accordion.php index 0bb5ce3..8674562 100644 --- a/src/Components/Accordion.php +++ b/src/Components/Accordion.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Accordion diff --git a/src/Components/Alert.php b/src/Components/Alert.php index aa55c00..77dffea 100644 --- a/src/Components/Alert.php +++ b/src/Components/Alert.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Alert @@ -109,18 +109,11 @@ private function renderDismissButton() { return Html::rawElement( 'button', [ - 'type' => 'button', - 'class' => 'close', - 'data-dismiss' => 'alert', - 'aria-label' => wfMessage( 'bootstrap-components-close-element' )->inContentLanguage()->text(), - ], - Html::rawElement( - 'span', - [ - 'aria-hidden' => 'true', - ], - '×' - ) + 'type' => 'button', + 'class' => 'btn-close', + 'data-bs-dismiss' => 'alert', + 'aria-label' => wfMessage( 'bootstrap-components-close-element' )->inContentLanguage()->text(), + ] ); } } diff --git a/src/Components/Badge.php b/src/Components/Badge.php index 1267cf2..36643d2 100644 --- a/src/Components/Badge.php +++ b/src/Components/Badge.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Badge @@ -72,7 +72,7 @@ private function calculateClassAttribute() { $class = [ 'badge' ]; if ( (bool)$this->getValueFor( 'pill' ) ) { - $class[] = 'badge-pill'; + $class[] = 'rounded-pill'; } $class[] = 'badge-' . $this->getValueFor( 'color', 'primary' ); diff --git a/src/Components/Button.php b/src/Components/Button.php index e4e0597..24d79f4 100644 --- a/src/Components/Button.php +++ b/src/Components/Button.php @@ -27,8 +27,8 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; -use \Title; +use MediaWiki\Html\Html; +use MediaWiki\Title\Title; /** * Class Button @@ -106,7 +106,12 @@ private function calculateClassAttribute() { if ( (bool)$this->getValueFor( 'outline' ) ) { $colorClass .= 'outline-'; } - $class[] = $colorClass . $this->getValueFor( 'color', 'primary' ); + // Bootstrap 5 doesn't have btn-default, map to btn-secondary + $color = $this->getValueFor( 'color', 'primary' ); + if ( $color === 'default' ) { + $color = 'secondary'; + } + $class[] = $colorClass . $color; if ( $size = $this->getValueFor( 'size' ) ) { $class[] = "btn-" . $size; } diff --git a/src/Components/Card.php b/src/Components/Card.php index 9d41e9a..5b6d9a3 100644 --- a/src/Components/Card.php +++ b/src/Components/Card.php @@ -26,12 +26,12 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; -use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; +use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use \Html; -use \MWException; +use MediaWiki\Html\Html; +use MWException; /** * Class Card @@ -93,7 +93,7 @@ protected function placeMe( $input ) { 'class' => $this->arrayToString( $innerClass, ' ' ), ]; if ( $this->isCollapsible() ) { - $innerAttributes['data-parent'] = $this->getDataParent(); + $innerAttributes['data-bs-parent'] = $this->getDataParent(); $innerAttributes['aria-labelledby'] = $this->getId() . '_header'; } @@ -250,11 +250,11 @@ private function processAdditionToCard( string $type ): string { if ( $type == 'header' ) { if ( $this->isCollapsible() ) { $newAttributes += [ - 'data-toggle' => 'collapse', - 'data-target' => '#' . $this->getId(), - 'aria-controls' => $this->getId(), - 'aria-expanded' => $this->getValueFor( 'active' ) ? 'true' : 'false', - 'id' => $this->getId() . '_header' + 'data-bs-toggle' => 'collapse', + 'data-bs-target' => '#' . $this->getId(), + 'aria-controls' => $this->getId(), + 'aria-expanded' => $this->getValueFor( 'active' ) ? 'true' : 'false', + 'id' => $this->getId() . '_header' ]; } $inside = Html::rawElement( diff --git a/src/Components/Carousel.php b/src/Components/Carousel.php index 936ec79..f11f168 100644 --- a/src/Components/Carousel.php +++ b/src/Components/Carousel.php @@ -28,7 +28,7 @@ use MediaWiki\Extension\BootstrapComponents\AbstractComponent; use MediaWiki\Extension\BootstrapComponents\ParserRequest; -use \Html; +use MediaWiki\Html\Html; /** * Class Carousel @@ -60,10 +60,10 @@ protected function placeMe( $input ) { Html::rawElement( 'div', [ - 'class' => $this->arrayToString( $class, ' ' ), - 'style' => $this->arrayToString( $style, ';' ), - 'id' => $this->getId(), - 'data-ride' => 'carousel', + 'class' => $this->arrayToString( $class, ' ' ), + 'style' => $this->arrayToString( $style, ';' ), + 'id' => $this->getId(), + 'data-bs-ride' => 'carousel', ], $this->generateIndicators( count( $images ) ) . Html::rawElement( @@ -87,19 +87,19 @@ private function buildControls() { return Html::rawElement( 'a', [ - 'class' => 'carousel-control-prev', - 'href' => '#' . $this->getId(), - 'role' => 'button', - 'data-slide' => 'prev', + 'class' => 'carousel-control-prev', + 'href' => '#' . $this->getId(), + 'role' => 'button', + 'data-bs-slide' => 'prev', ], Html::rawElement( 'span', [ 'class' => 'carousel-control-prev-icon', 'aria-hidden' => 'true' ] ) ) . Html::rawElement( 'a', [ - 'class' => 'carousel-control-next', - 'href' => '#' . $this->getId(), - 'role' => 'button', - 'data-slide' => 'next', + 'class' => 'carousel-control-next', + 'href' => '#' . $this->getId(), + 'role' => 'button', + 'data-bs-slide' => 'next', ], Html::rawElement( 'span', [ 'class' => 'carousel-control-next-icon', 'aria-hidden' => 'true' ] ) ); @@ -188,9 +188,9 @@ private function generateIndicators( $num ) { $inner .= "\t" . Html::rawElement( 'li', [ - 'data-target' => '#' . $this->getId(), - 'data-slide-to' => $i, - 'class' => $class, + 'data-bs-target' => '#' . $this->getId(), + 'data-bs-slide-to' => $i, + 'class' => $class, ] ) . PHP_EOL; $class = false; diff --git a/src/Components/Collapse.php b/src/Components/Collapse.php index 838393c..130b5f8 100644 --- a/src/Components/Collapse.php +++ b/src/Components/Collapse.php @@ -26,11 +26,11 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; -use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; +use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; use MediaWiki\Extension\BootstrapComponents\ParserRequest; -use \Html; -use \MWException; +use MediaWiki\Html\Html; +use MWException; /** * Class Collapse @@ -74,7 +74,7 @@ protected function placeMe( $input ) { */ private function generateButton( ParserRequest $parserRequest ) { $button = new Button( $this->getComponentLibrary(), $this->getParserOutputHelper(), $this->getNestingController() ); - $button->injectRawAttributes( [ 'data-toggle' => 'collapse' ] ); + $button->injectRawAttributes( [ 'data-bs-toggle' => 'collapse' ] ); $buttonAttributes = $parserRequest->getAttributes(); unset( $buttonAttributes['id'] ); diff --git a/src/Components/Jumbotron.php b/src/Components/Jumbotron.php index fc75de7..eea89a1 100644 --- a/src/Components/Jumbotron.php +++ b/src/Components/Jumbotron.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Jumbotron @@ -44,9 +44,17 @@ class Jumbotron extends AbstractComponent { * @param string $input */ protected function placeMe( $input ) { - list ( $class, $style ) = $this->processCss( 'jumbotron', [] ); + // Bootstrap 5 removed .jumbotron class + // Recreate it using Bootstrap 5 utility classes as per https://getbootstrap.com/docs/5.3/examples/jumbotron/ + $class = [ + 'p-5', // padding + 'mb-4', // margin-bottom + 'bg-body-tertiary', // background color (Bootstrap 5.3) + 'rounded-3' // border-radius + ]; + + list ( $class, $style ) = $this->processCss( $class, [] ); # @hack: the outer container is a workaround, to get all the necessary css if not inside a grid container - # @fixme: used inside mw content, the width calculation for smaller screens is broken (as of Bootstrap 1.2.3) return Html::rawElement( 'div', [ diff --git a/src/Components/Modal.php b/src/Components/Modal.php index 935bc61..7870215 100644 --- a/src/Components/Modal.php +++ b/src/Components/Modal.php @@ -29,7 +29,7 @@ use MediaWiki\Extension\BootstrapComponents\AbstractComponent; use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; use MediaWiki\Extension\BootstrapComponents\ModalBuilder; -use \Html; +use MediaWiki\Html\Html; /** * Class Modal @@ -102,13 +102,18 @@ private function calculateInnerClass() { * @return string */ private function generateButton( $text ) { + // Bootstrap 5 doesn't have btn-default, map to btn-secondary + $color = $this->getValueFor( 'color', 'secondary' ); + if ( $color === 'default' ) { + $color = 'secondary'; + } return Html::rawElement( 'button', [ - 'type' => 'button', - 'class' => 'modal-trigger btn btn-' . $this->getValueFor( 'color', 'default' ), - 'data-toggle' => 'modal', - 'data-target' => '#' . $this->getId(), + 'type' => 'button', + 'class' => 'modal-trigger btn btn-' . $color, + 'data-bs-toggle' => 'modal', + 'data-bs-target' => '#' . $this->getId(), ], $text ); diff --git a/src/Components/Popover.php b/src/Components/Popover.php index 15b4195..f222ab9 100644 --- a/src/Components/Popover.php +++ b/src/Components/Popover.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Popover @@ -87,11 +87,11 @@ private function buildHtmlElements( $input, $text, $heading ) { $attributes = array_merge( $attributes, [ - 'data-toggle' => 'popover', - 'title' => $heading, - 'data-content' => str_replace( "\n", " ", trim( $input ) ), - 'data-placement' => $this->getValueFor( 'placement' ), - 'data-trigger' => $this->getValueFor( 'trigger' ), + 'data-bs-toggle' => 'popover', + 'title' => $heading, + 'data-bs-content' => str_replace( "\n", " ", trim( $input ) ), + 'data-bs-placement' => $this->getValueFor( 'placement' ), + 'data-bs-trigger' => $this->getValueFor( 'trigger' ), ] ); $tag = "button"; @@ -109,7 +109,12 @@ private function buildHtmlElements( $input, $text, $heading ) { * @return string[] */ private function calculatePopoverClassAttribute() { - $class = [ 'btn', 'btn-' . $this->getValueFor( 'color', 'info' ) ]; + // Bootstrap 5 doesn't have btn-default, map to btn-secondary + $color = $this->getValueFor( 'color', 'info' ); + if ( $color === 'default' ) { + $color = 'secondary'; + } + $class = [ 'btn', 'btn-' . $color ]; if ( $size = $this->getValueFor( 'size' ) ) { $class[] = 'btn-' . $size; } diff --git a/src/Components/Tooltip.php b/src/Components/Tooltip.php index a73ba0e..ebe5d9b 100644 --- a/src/Components/Tooltip.php +++ b/src/Components/Tooltip.php @@ -27,7 +27,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Components; use MediaWiki\Extension\BootstrapComponents\AbstractComponent; -use \Html; +use MediaWiki\Html\Html; /** * Class Tooltip @@ -85,9 +85,9 @@ private function buildHtmlElements( $input, $tooltip ) { $attributes = array_merge( $attributes, [ - 'data-placement' => $this->getValueFor( 'placement' ), - 'data-toggle' => 'tooltip', - 'title' => $tooltip, + 'data-bs-placement' => $this->getValueFor( 'placement' ), + 'data-bs-toggle' => 'tooltip', + 'title' => $tooltip, ] ); $tag = "span"; diff --git a/src/Hooks/OutputPageParserOutput.php b/src/Hooks/OutputPageParserOutput.php index 64dae49..fd72a76 100644 --- a/src/Hooks/OutputPageParserOutput.php +++ b/src/Hooks/OutputPageParserOutput.php @@ -28,13 +28,8 @@ use MediaWiki\Extension\BootstrapComponents\BootstrapComponents; use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; -/* - * TODO switch to these, wehen we drop support for mw < 1.40 use MediaWiki\Output\OutputPage; use MediaWiki\Parser\ParserOutput; - */ -use \OutputPage; -use \ParserOutput; /** * Class OutputPageParserOutput diff --git a/src/Hooks/ParserFirstCallInit.php b/src/Hooks/ParserFirstCallInit.php index 0adbe14..888ce71 100644 --- a/src/Hooks/ParserFirstCallInit.php +++ b/src/Hooks/ParserFirstCallInit.php @@ -31,7 +31,7 @@ use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use Parser; +use MediaWiki\Parser\Parser; use ReflectionClass; /** diff --git a/src/HooksHandler.php b/src/HooksHandler.php index 475142f..e0b47ca 100644 --- a/src/HooksHandler.php +++ b/src/HooksHandler.php @@ -14,9 +14,7 @@ use MediaWiki\Hook\ParserFirstCallInitHook; use MediaWiki\Hook\SetupAfterCacheHook; use MediaWiki\MediaWikiServices; -use Parser; -// TODO switch to then when dropping support for mw < 1.40 -// use MediaWiki\Parser\Parser; +use MediaWiki\Parser\Parser; use SMW\Utils\File; use StripState; diff --git a/src/ImageModal.php b/src/ImageModal.php index 455f0cb..8b78d72 100644 --- a/src/ImageModal.php +++ b/src/ImageModal.php @@ -27,11 +27,11 @@ namespace MediaWiki\Extension\BootstrapComponents; use File; -use Html; use MediaTransformOutput; +use MediaWiki\Html\Html; use MediaWiki\MediaWikiServices; +use MediaWiki\Title\Title; use MWException; -use Title; /** * Class ImageModal diff --git a/src/ImageModalTrigger.php b/src/ImageModalTrigger.php index 0555c8b..91ef141 100644 --- a/src/ImageModalTrigger.php +++ b/src/ImageModalTrigger.php @@ -29,12 +29,11 @@ use Config; use ConfigException; use Exception; -use \Linker; -use \Html; -use \MediaWiki\MediaWikiServices; -use MediaWiki\User\UserOptionsLookup; -use \RequestContext; -use \Title; +use MediaWiki\Html\Html; +use MediaWiki\Linker\Linker; +use MediaWiki\MediaWikiServices; +use MediaWiki\Title\Title; +use RequestContext; /** * Class ImageModal diff --git a/src/LuaLibrary.php b/src/LuaLibrary.php index 0a0266a..73a4d0d 100644 --- a/src/LuaLibrary.php +++ b/src/LuaLibrary.php @@ -26,12 +26,12 @@ namespace MediaWiki\Extension\BootstrapComponents; +use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LibraryBase; +use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LuaEngine; use MediaWiki\MediaWikiServices; use MWException; use ReflectionClass; use ReflectionException; -use Scribunto_LuaEngine; -use Scribunto_LuaLibraryBase; /** * Class LuaLibrary @@ -40,7 +40,7 @@ * * @since 1.1 */ -class LuaLibrary extends Scribunto_LuaLibraryBase { +class LuaLibrary extends LibraryBase { /** * @var ApplicationFactory $applicationFactory; @@ -55,9 +55,9 @@ class LuaLibrary extends Scribunto_LuaLibraryBase { /** * LuaLibrary constructor. * - * @param Scribunto_LuaEngine $engine + * @param LuaEngine $engine */ - public function __construct( Scribunto_LuaEngine $engine ) { + public function __construct( LuaEngine $engine ) { parent::__construct( $engine ); $this->applicationFactory = ApplicationFactory::getInstance(); $this->bootstrapComponentService = MediaWikiServices::getInstance()->getService( 'BootstrapComponentsService' ); diff --git a/src/ModalBuilder.php b/src/ModalBuilder.php index d1b6f23..9226367 100644 --- a/src/ModalBuilder.php +++ b/src/ModalBuilder.php @@ -26,8 +26,7 @@ namespace MediaWiki\Extension\BootstrapComponents; -use \Html; -use MediaWiki\MediaWikiServices; +use MediaWiki\Html\Html; /** * Class ModalBase @@ -123,9 +122,9 @@ public static function wrapTriggerElement( $element, $id ) { return Html::rawElement( 'span', [ - 'class' => 'modal-trigger', - 'data-toggle' => 'modal', - 'data-target' => '#' . $id, + 'class' => 'modal-trigger', + 'data-bs-toggle' => 'modal', + 'data-bs-target' => '#' . $id, ], $element ); @@ -331,8 +330,8 @@ protected function buildModal() { */ protected function buildTrigger() { $trigger = $this->getTrigger(); - if ( preg_match( '/data-toggle[^"]+"modal/', $trigger ) - && preg_match( '/data-target[^"]+"#' . $this->getId() . '"/', $trigger ) + if ( preg_match( '/data-bs-toggle[^"]+"modal/', $trigger ) + && preg_match( '/data-bs-target[^"]+"#' . $this->getId() . '"/', $trigger ) && preg_match( '/class[^"]+"[^"]*modal-trigger' . '/', $trigger ) ) { return $trigger; @@ -472,10 +471,10 @@ private function generateFooter( $footer = '' ) { $footer . Html::rawElement( 'button', [ - 'type' => 'button', - 'class' => 'btn btn-default', - 'data-dismiss' => 'modal', - 'aria-label' => $close, + 'type' => 'button', + 'class' => 'btn btn-secondary', + 'data-bs-dismiss' => 'modal', + 'aria-label' => $close, ], $close ) @@ -502,16 +501,11 @@ private function generateHeader( $header = '' ) { $button = Html::rawElement( 'button', [ - 'type' => 'button', - 'class' => 'close', - 'data-dismiss' => 'modal', - 'aria-label' => wfMessage( 'bootstrap-components-close-element' )->inContentLanguage()->text(), - ], - Html::rawElement( - 'span', - [ 'aria-hidden' => 'true' ], - '×' - ) + 'type' => 'button', + 'class' => 'btn-close', + 'data-bs-dismiss' => 'modal', + 'aria-label' => wfMessage( 'bootstrap-components-close-element' )->inContentLanguage()->text(), + ] ); return Html::rawElement( 'div', diff --git a/src/ParserOutputHelper.php b/src/ParserOutputHelper.php index 9877ff0..0c1962e 100644 --- a/src/ParserOutputHelper.php +++ b/src/ParserOutputHelper.php @@ -26,20 +26,11 @@ namespace MediaWiki\Extension\BootstrapComponents; -/* - * TODO: When dropping support for MW1.39, use these class imports: use MediaWiki\Html\Html; use MediaWiki\Message\Message; use MediaWiki\Parser\Parser; use MediaWiki\Parser\ParserOutput; use MediaWiki\Title\Title; -*/ - -use Html; -use Message; -use Parser; -use ParserOutput; -use Title; /** diff --git a/src/ParserRequest.php b/src/ParserRequest.php index 20dfa3f..691f9ae 100644 --- a/src/ParserRequest.php +++ b/src/ParserRequest.php @@ -26,8 +26,8 @@ namespace MediaWiki\Extension\BootstrapComponents; +use MediaWiki\Parser\Parser; use MWException; -use Parser; use PPFrame; /** diff --git a/tests/PhpUnitEnvironment.php b/tests/PhpUnitEnvironment.php index f4dbc06..e98be58 100644 --- a/tests/PhpUnitEnvironment.php +++ b/tests/PhpUnitEnvironment.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests; -use \GitInfo; +use GitInfo; /** * @private diff --git a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php index 474dbb6..af5e1b3 100644 --- a/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php +++ b/tests/phpunit/Integration/I18nJsonFileIntegrityTest.php @@ -2,7 +2,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Integration; -use \MediaWiki\MediaWikiServices; +use MediaWiki\MediaWikiServices; use SMW\Tests\PHPUnitCompat; use SMW\Tests\Utils\UtilityFactory; diff --git a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php index 574ccd2..e1e44d5 100644 --- a/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php +++ b/tests/phpunit/Integration/JSONScript/BootstrapComponentsJsonTestCaseScriptRunnerTest.php @@ -3,8 +3,8 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Integration; use MediaWiki\Extension\BootstrapComponents\ApplicationFactory; -use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; use MediaWiki\Extension\BootstrapComponents\HookRegistry; +use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; use SMW\DIWikiPage; use SMW\Tests\JSONScriptTestCaseRunner; use SMW\Tests\Utils\JSONScript\JsonTestCaseFileHandler; diff --git a/tests/phpunit/Unit/CarouselGalleryTest.php b/tests/phpunit/Unit/CarouselGalleryTest.php index be566f6..70cd108 100644 --- a/tests/phpunit/Unit/CarouselGalleryTest.php +++ b/tests/phpunit/Unit/CarouselGalleryTest.php @@ -3,10 +3,9 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\CarouselGallery; -use MediaWiki\Extension\BootstrapComponents\ParserRequest; -use \MWException; +use MediaWiki\Title\Title; +use MWException; use PHPUnit\Framework\TestCase; -use \Title; /** * @covers \MediaWiki\Extension\BootstrapComponents\CarouselGallery @@ -83,17 +82,17 @@ public function galleryDataProvider() { 'fade' => '', ], [ - 0 => '
', 'isHTML' => true, 'noparse' => true, ], @@ -105,15 +104,15 @@ public function galleryDataProvider() { ], [], [ - 0 => '', 'isHTML' => true, 'noparse' => true, ], diff --git a/tests/phpunit/Unit/Components/AccordionTest.php b/tests/phpunit/Unit/Components/AccordionTest.php index 657cc11..9e7977e 100644 --- a/tests/phpunit/Unit/Components/AccordionTest.php +++ b/tests/phpunit/Unit/Components/AccordionTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Accordion as Accordion; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Accordion diff --git a/tests/phpunit/Unit/Components/AlertTest.php b/tests/phpunit/Unit/Components/AlertTest.php index 55d7de8..4e0abfa 100644 --- a/tests/phpunit/Unit/Components/AlertTest.php +++ b/tests/phpunit/Unit/Components/AlertTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Alert; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Alert @@ -91,17 +91,17 @@ public function placeMeArgumentsProvider() { 'dismiss_arbitrary' => [ $this->input, [ 'dismissible' => 'bla' ], - '', + '', ], 'dismiss' => [ $this->input, [ 'dismissible' => true ], - '', + '', ], 'fading' => [ $this->input, [ 'dismissible' => 'fade', 'color' => 'warning' ], - '', + '', ], 'manual id, no dismiss' => [ $this->input, diff --git a/tests/phpunit/Unit/Components/BadgeTest.php b/tests/phpunit/Unit/Components/BadgeTest.php index 1550ad4..3603f1b 100644 --- a/tests/phpunit/Unit/Components/BadgeTest.php +++ b/tests/phpunit/Unit/Components/BadgeTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Badge; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Badge @@ -89,7 +89,7 @@ public function placeMeArgumentsProvider() { 'pill' => [ $this->input, [ 'pill' => 'true' ], - '' . $this->input . '', + '' . $this->input . '', ], 'no pill' => [ $this->input, diff --git a/tests/phpunit/Unit/Components/ButtonTest.php b/tests/phpunit/Unit/Components/ButtonTest.php index da6e560..12234e1 100644 --- a/tests/phpunit/Unit/Components/ButtonTest.php +++ b/tests/phpunit/Unit/Components/ButtonTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Button; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Button @@ -85,7 +85,7 @@ public function testCanInjectRawAttributes() { ); $instance->injectRawAttributes( - [ 'data-toggle' => 'foo', 'data-target' => '#bar' ] + [ 'data-bs-toggle' => 'foo', 'data-bs-target' => '#bar' ] ); $generatedOutput = $instance->parseComponent( $parserRequest ); @@ -98,14 +98,14 @@ public function testCanInjectRawAttributes() { $this->assertRegExp( '~^' . $this->input . '$~', + . '" data-bs-toggle="foo" data-bs-target="#bar">' . $this->input . '$~', $generatedOutput ); } else { $this->assertMatchesRegularExpression( '~^' . $this->input . '$~', + . '" data-bs-toggle="foo" data-bs-target="#bar">' . $this->input . '$~', $generatedOutput ); } diff --git a/tests/phpunit/Unit/Components/CardTest.php b/tests/phpunit/Unit/Components/CardTest.php index f7d4563..994d21a 100644 --- a/tests/phpunit/Unit/Components/CardTest.php +++ b/tests/phpunit/Unit/Components/CardTest.php @@ -6,7 +6,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Card; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Card @@ -148,7 +148,7 @@ public function placeMeArgumentsProvider() { 'footer-style'=> 'padding:5px', ], '
' - . '
' + . '
' . '

HEADING TEXT

[[File:Serenity.png]]' . '
' . $this->input . '
[[File:Serenity.png|class=card-img-bottom]]
', @@ -179,12 +179,12 @@ public function placeMeInsideAccordionArgumentsProvider() { 'simple' => [ $this->input, [], - '
' . $this->input . '
', + '
' . $this->input . '
', ], 'text missing' => [ '', [ 'header' => 'watch this', 'footer' => 'watch what?', 'collapsible' => 'false', ], - '
', + '
', ], 'all attributes' => [ $this->input, @@ -198,12 +198,12 @@ public function placeMeInsideAccordionArgumentsProvider() { 'heading' => 'HEADING TEXT', 'footer' => 'FOOTER TEXT', ], - '

HEADING TEXT

' . $this->input . '
', + '

HEADING TEXT

' . $this->input . '
', ], 'collapsible false' => [ $this->input, [ 'collapsible' => 'false', ], - '
' . $this->input . '
', + '
' . $this->input . '
', ], ]; } diff --git a/tests/phpunit/Unit/Components/CarouselTest.php b/tests/phpunit/Unit/Components/CarouselTest.php index 5be1384..1c10d12 100644 --- a/tests/phpunit/Unit/Components/CarouselTest.php +++ b/tests/phpunit/Unit/Components/CarouselTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Carousel; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Carousel @@ -79,17 +79,17 @@ public function placeMeArgumentsProvider() { 'simple' => [ '[[File:Mal.jpg|Malcolm Reynolds_0]]', [ '[[File:Mal.jpg|Malcolm Reynolds]]' => true, '[[File:Wash.jpg|link' => '|Hoban Washburne]]' ], - '
', ], 'images missing' => [ $this->input, @@ -105,15 +105,15 @@ public function placeMeArgumentsProvider() { 'fade' => true, 'style' => 'float:none;background-color:black', ], - '', ], ]; } diff --git a/tests/phpunit/Unit/Components/CollapseTest.php b/tests/phpunit/Unit/Components/CollapseTest.php index 04c4ba9..557a0ea 100644 --- a/tests/phpunit/Unit/Components/CollapseTest.php +++ b/tests/phpunit/Unit/Components/CollapseTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Collapse; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Collapse @@ -69,27 +69,27 @@ public function placeMeArgumentsProvider() { 'simple' => [ $this->input, [], - '#bsc_collapse_NULL
' . $this->input . '
', + '#bsc_collapse_NULL
' . $this->input . '
', ], 'color_unknown' => [ $this->input, [ 'color' => 'unknown' ], - '#bsc_collapse_NULL
' . $this->input . '
', + '#bsc_collapse_NULL
' . $this->input . '
', ], 'button text' => [ $this->input, [ 'text' => 'BUTTON' ], - 'BUTTON
' . $this->input . '
', + 'BUTTON
' . $this->input . '
', ], 'manual id' => [ $this->input, [ 'color' => 'success', 'id' => 'alliance' ], - '#alliance
' . $this->input . '
', + '#alliance
' . $this->input . '
', ], 'style and class' => [ $this->input, [ 'class' => 'dummy nice', 'style' => 'float:right;background-color:green' ], - '#bsc_collapse_NULL
' . $this->input . '
', + '#bsc_collapse_NULL
' . $this->input . '
', ], ]; } diff --git a/tests/phpunit/Unit/Components/JumbotronTest.php b/tests/phpunit/Unit/Components/JumbotronTest.php index 024457b..7d15ebf 100644 --- a/tests/phpunit/Unit/Components/JumbotronTest.php +++ b/tests/phpunit/Unit/Components/JumbotronTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Jumbotron; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Jumbotron @@ -69,17 +69,17 @@ public function placeMeArgumentsProvider() { 'simple' => [ $this->input, [], - '
' . $this->input . '
', + '
' . $this->input . '
', ], 'manual id' => [ $this->input, [ 'id' => 'hms_dortmunder' ], - '
' . $this->input . '
', + '
' . $this->input . '
', ], 'style and class' => [ $this->input, [ 'class' => 'dummy nice', 'style' => 'float:right;background-color:green' ], - '
' . $this->input . '
', + '
' . $this->input . '
', ], ]; } diff --git a/tests/phpunit/Unit/Components/ModalTest.php b/tests/phpunit/Unit/Components/ModalTest.php index f0d6991..d6f9be7 100644 --- a/tests/phpunit/Unit/Components/ModalTest.php +++ b/tests/phpunit/Unit/Components/ModalTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Modal; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Modal @@ -89,9 +89,9 @@ public function placeMeArgumentsProvider() { 'simple' => [ $this->input, [ 'text' => 'BUTTON' ], - '', - '' . "\n", + '', + '' . "\n", ], 'text missing' => [ $this->input, @@ -105,9 +105,9 @@ public function placeMeArgumentsProvider() { 'text' => 'beforeSerenityafter', 'size' => 'none', ], - 'beforeSerenityafter', - '' . "\n", + 'beforeSerenityafter', + '' . "\n", ], 'all attributes' => [ $this->input, @@ -116,9 +116,9 @@ public function placeMeArgumentsProvider() { 'id' => 'firefly0', 'size' => 'lg', 'class' => 'shiny', 'style' => 'float:right;background-color:black', 'heading' => 'You can\'t take the sky from me!', ], - 'Serenity', - '' . "\n", + 'Serenity', + '' . "\n", ], ]; } diff --git a/tests/phpunit/Unit/Components/PopoverTest.php b/tests/phpunit/Unit/Components/PopoverTest.php index ef44556..3714c8a 100644 --- a/tests/phpunit/Unit/Components/PopoverTest.php +++ b/tests/phpunit/Unit/Components/PopoverTest.php @@ -4,7 +4,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Popover; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Popover @@ -69,7 +69,7 @@ public function placeMeArgumentsProvider() { 'simple' => [ $this->input, [ 'heading' => 'heading', 'text' => 'BUTTON' ], - '', + '', ], 'heading empty' => [ $this->input, @@ -87,7 +87,7 @@ public function placeMeArgumentsProvider() { 'heading' => 'heading', 'text' => 'BUTTON', 'class' => 'dummy nice', 'style' => 'float:right;background-color:green', 'placement' => 'right', 'trigger' => 'hover', 'id' => 'cudgel', 'size' => 'sm' ], - '', + '', ], ]; } diff --git a/tests/phpunit/Unit/Components/TooltipTest.php b/tests/phpunit/Unit/Components/TooltipTest.php index 8fee9eb..5d76d00 100644 --- a/tests/phpunit/Unit/Components/TooltipTest.php +++ b/tests/phpunit/Unit/Components/TooltipTest.php @@ -5,7 +5,7 @@ use MediaWiki\Extension\BootstrapComponents\Components\Tooltip; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\Tests\Unit\ComponentsTestBase; -use \MWException; +use MWException; /** * @covers \MediaWiki\Extension\BootstrapComponents\Components\Tooltip @@ -74,7 +74,7 @@ public function placeMeArgumentsProvider() { 'simple' => [ $this->input, [ 'text' => 'simple' ], - '' . $this->input . '', + '' . $this->input . '', ], 'empty' => [ '', @@ -89,7 +89,7 @@ public function placeMeArgumentsProvider() { 'id, style and class' => [ $this->input, [ 'text' => 'simple', 'class' => 'dummy nice', 'style' => 'float:right;background-color:#80266e', 'id' => 'vera' ], - '' . $this->input . '', + '' . $this->input . '', ], ]; } diff --git a/tests/phpunit/Unit/ComponentsTestBase.php b/tests/phpunit/Unit/ComponentsTestBase.php index c7ef2ab..fe87f60 100644 --- a/tests/phpunit/Unit/ComponentsTestBase.php +++ b/tests/phpunit/Unit/ComponentsTestBase.php @@ -6,8 +6,8 @@ use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; use MediaWiki\Extension\BootstrapComponents\ParserRequest; +use MediaWiki\Parser\Parser; use PHPUnit\Framework\TestCase; -use Parser; use PPFrame; /** diff --git a/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php b/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php index e7d97fb..0ece4ac 100644 --- a/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php +++ b/tests/phpunit/Unit/Hooks/OutputPageParserOutputTest.php @@ -4,8 +4,8 @@ use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Extension\BootstrapComponents\Hooks\OutputPageParserOutput; -use OutputPage; -use ParserOutput; +use MediaWiki\Output\OutputPage; +use MediaWiki\Parser\ParserOutput; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php b/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php index e1b32ea..90d1fbf 100644 --- a/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php +++ b/tests/phpunit/Unit/Hooks/ParserFirstCallInitTest.php @@ -2,9 +2,9 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit\Hooks; -use MediaWiki\Extension\BootstrapComponents\Hooks\ParserFirstCallInit as ParserFirstCallInit; use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; -use \Parser; +use MediaWiki\Extension\BootstrapComponents\Hooks\ParserFirstCallInit as ParserFirstCallInit; +use MediaWiki\Parser\Parser; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/ImageModalTest.php b/tests/phpunit/Unit/ImageModalTest.php index a4ef194..69306f5 100644 --- a/tests/phpunit/Unit/ImageModalTest.php +++ b/tests/phpunit/Unit/ImageModalTest.php @@ -2,17 +2,17 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; +use ConfigException; use File; use LocalFile; use MediaWiki\Extension\BootstrapComponents\BootstrapComponentsService; use MediaWiki\Extension\BootstrapComponents\ImageModal; -use \ConfigException; use MediaWiki\Extension\BootstrapComponents\NestingController; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use \MediaWiki\MediaWikiServices; +use MediaWiki\MediaWikiServices; +use MediaWiki\Title\Title; use PHPUnit\Framework\TestCase; use ThumbnailImage; -use Title; /** * @covers \MediaWiki\Extension\BootstrapComponents\ImageModal @@ -309,9 +309,9 @@ public function canParseDataProvider(): array 'no params' => [ [], [], - '~~', - '' . "\n", + '~~', + '' . "\n", ], 'frame params w/o thumbnail' => [ [ @@ -323,9 +323,9 @@ public function canParseDataProvider(): array 'valign' => 'text-top', ], [], - '~
test_alt
~', - '' . "\n", + '~
test_alt
~', + '' . "\n", ], 'manual width, frameless' => [ [ @@ -336,9 +336,9 @@ public function canParseDataProvider(): array 'width' => 200, 'page' => 7, ], - '~
~', - '' . "\n", + '~
~', + '' . "\n", ], 'thumbnail, manual width' => [ [ @@ -349,9 +349,9 @@ public function canParseDataProvider(): array 'width' => 200, 'page' => 7, ], - '~
~', - '' . "\n", + '~
~', + '' . "\n", ], 'manual thumbnail, NOT centered' => [ [ @@ -360,9 +360,9 @@ public function canParseDataProvider(): array 'framed' => false, ], [], - '~
()?()?
~', - '' . "\n", + '~
~', + '' . "\n", ], 'framed' => [ [ @@ -370,9 +370,9 @@ public function canParseDataProvider(): array 'framed' => false, ], [], - '~
~', - '' . "\n", + '~
~', + '' . "\n", ], 'centered' => [ [ @@ -381,9 +381,9 @@ public function canParseDataProvider(): array [ 'width' => 200, ], - '~
~', - '' . "\n", + '~
~', + '' . "\n", ], 'manual thumbnail, upright' => [ [ @@ -392,9 +392,9 @@ public function canParseDataProvider(): array 'manualthumb' => 'Shuttle.png', ], [], - '~
()?()?
~', - '' . "\n", + '~
~', + '' . "\n", ], ]; } diff --git a/tests/phpunit/Unit/ImageModalTriggerTest.php b/tests/phpunit/Unit/ImageModalTriggerTest.php index f80e549..d64d37b 100644 --- a/tests/phpunit/Unit/ImageModalTriggerTest.php +++ b/tests/phpunit/Unit/ImageModalTriggerTest.php @@ -3,7 +3,7 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\ImageModalTrigger; -use \MediaWiki\MediaWikiServices; +use MediaWiki\MediaWikiServices; use PHPUnit\Framework\TestCase; /** @@ -172,7 +172,7 @@ public function canParseProvider() { 'page' => false, ], [ - '~~', + '~~', ] ], 'frame params w/o thumbnail' => [ @@ -192,7 +192,7 @@ public function canParseProvider() { 'page' => false, ], [ - '~
~', + '~
~', '~test_alt~', ] ], @@ -214,7 +214,7 @@ public function canParseProvider() { 'page' => 7, ], [ - '~
~', + '~
~', '~~', ] ], @@ -236,7 +236,7 @@ public function canParseProvider() { 'page' => 7, ], [ - '~
~', + '~
~', '~
~', '~
~', ] @@ -260,9 +260,9 @@ public function canParseProvider() { 'page' => false, ], [ - '~
~', + '~
~', '~
~', - '~~', + '~~', ] ], 'framed' => [ @@ -282,7 +282,7 @@ public function canParseProvider() { 'page' => false, ], [ - '~
~', + '~
~', '~
~', ] ], @@ -304,7 +304,7 @@ public function canParseProvider() { 'page' => false, ], [ - '~
~', + '~
~', ] ], 'manual thumbnail, upright' => [ @@ -326,8 +326,8 @@ public function canParseProvider() { 'page' => false, ], [ - '~
~', - '~~', + '~' . "\n", ], 'scarce' => [ 'id1', @@ -113,9 +113,9 @@ public function parseDataProvider() { '', '', '', - 'trigger1', - '' . "\n", + 'trigger1', + '' . "\n", ], ]; } diff --git a/tests/phpunit/Unit/ParserOutputHelperTest.php b/tests/phpunit/Unit/ParserOutputHelperTest.php index 5fda1a2..a5c4b9c 100644 --- a/tests/phpunit/Unit/ParserOutputHelperTest.php +++ b/tests/phpunit/Unit/ParserOutputHelperTest.php @@ -4,10 +4,9 @@ use MediaWiki\Extension\BootstrapComponents\ComponentLibrary; use MediaWiki\Extension\BootstrapComponents\ParserOutputHelper; -use \MWException; -// TODO: when dropping 1.39, switch to MediaWiki\Parser\Parser and MediaWiki\Parser\ParserOutput -use Parser; -use ParserOutput; +use MediaWiki\Parser\Parser; +use MediaWiki\Parser\ParserOutput; +use MWException; use PHPUnit\Framework\TestCase; /** diff --git a/tests/phpunit/Unit/ParserRequestTest.php b/tests/phpunit/Unit/ParserRequestTest.php index a448625..28bfb50 100644 --- a/tests/phpunit/Unit/ParserRequestTest.php +++ b/tests/phpunit/Unit/ParserRequestTest.php @@ -3,9 +3,9 @@ namespace MediaWiki\Extension\BootstrapComponents\Tests\Unit; use MediaWiki\Extension\BootstrapComponents\ParserRequest; +use MediaWiki\Parser\Parser; use PHPUnit\Framework\TestCase; -use \Parser; -use \PPFrame; +use PPFrame; /** * @covers \MediaWiki\Extension\BootstrapComponents\ParserRequest diff --git a/tests/phpunit/Unit/mw.bootstrap.parse.tests.lua b/tests/phpunit/Unit/mw.bootstrap.parse.tests.lua index a62be76..cdd035f 100644 --- a/tests/phpunit/Unit/mw.bootstrap.parse.tests.lua +++ b/tests/phpunit/Unit/mw.bootstrap.parse.tests.lua @@ -55,7 +55,7 @@ local tests = { return removeId ( mw.bootstrap.parse( component, input, args ) ) end, args = { 'alert', 'Alert content', { color = 'success', dismissible = 'fade', noStrip = true } }, - expect = { '' } + expect = { '' } }, }