aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
diff options
context:
space:
mode:
authorTimo Tijhof <krinkle@fastmail.com>2023-11-01 00:44:47 +0000
committerTimo Tijhof <krinkle@fastmail.com>2024-07-05 19:28:14 +0100
commitfaf4cb33846978c32e6157682a8b06dd00faf3b1 (patch)
tree73eddff06c4d58dde15d9718325fed29801885b3 /tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
parentc86466f5dcf24c9ce51c482f1b7796bf511ad1d8 (diff)
downloadmediawikicore-faf4cb33846978c32e6157682a8b06dd00faf3b1.tar.gz
mediawikicore-faf4cb33846978c32e6157682a8b06dd00faf3b1.zip
content: Improve roundtrip tests for JavaScriptContent
* Re-use the same data provider explicitly instead of manually keeping them in sync. * Add test case names as array keys to improve debugging. * Widen `@covers` annotations in unit tests. Bug: T107289 Change-Id: I9a321400855ddd1f56334f6ecf85590fd8ed4aaf
Diffstat (limited to 'tests/phpunit/includes/content/JavaScriptContentHandlerTest.php')
-rw-r--r--tests/phpunit/includes/content/JavaScriptContentHandlerTest.php21
1 files changed, 11 insertions, 10 deletions
diff --git a/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php b/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
index 7e257da65291..a71b08f28b95 100644
--- a/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
+++ b/tests/phpunit/includes/content/JavaScriptContentHandlerTest.php
@@ -5,11 +5,13 @@ use MediaWiki\Content\JavaScriptContentHandler;
use MediaWiki\MainConfigNames;
use MediaWiki\Title\Title;
+/**
+ * @covers \JavaScriptContentHandler
+ */
class JavaScriptContentHandlerTest extends MediaWikiLangTestCase {
/**
* @dataProvider provideMakeRedirectContent
- * @covers \MediaWiki\Content\JavaScriptContentHandler::makeRedirectContent
*/
public function testMakeRedirectContent( $title, $expected ) {
$this->overrideConfigValues( [
@@ -23,31 +25,30 @@ class JavaScriptContentHandlerTest extends MediaWikiLangTestCase {
}
/**
- * Keep this in sync with JavaScriptContentTest::provideGetRedirectTarget()
+ * This is re-used by JavaScriptContentTest to assert roundtrip
*/
public static function provideMakeRedirectContent() {
return [
- [
+ 'MediaWiki namespace page' => [
'MediaWiki:MonoBook.js',
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=MediaWiki:MonoBook.js&action=raw&ctype=text/javascript");'
],
- [
+ 'User subpage' => [
'User:FooBar/common.js',
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:FooBar/common.js&action=raw&ctype=text/javascript");'
],
- [
+ 'Gadget page' => [
'Gadget:FooBaz.js',
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=Gadget:FooBaz.js&action=raw&ctype=text/javascript");'
],
- [
+ 'Unicode basename' => [
'User:😂/unicode.js',
'/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:%F0%9F%98%82/unicode.js&action=raw&ctype=text/javascript");'
],
- [
- 'User:A&B/ampersand.js',
- '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:A%26B/ampersand.js&action=raw&ctype=text/javascript");'
+ 'Ampersand basename' => [
+ 'User:Penn & Teller/ampersand.js',
+ '/* #REDIRECT */mw.loader.load("//example.org/w/index.php?title=User:Penn_%26_Teller/ampersand.js&action=raw&ctype=text/javascript");'
],
];
- // phpcs:enable
}
}