Umherirrender has uploaded a new change for review.
https://gerrit.wikimedia.org/r/104016
Change subject: Add more tests for title validations
......................................................................
Add more tests for title validations
Change-Id: I407355295b65bc67eb171da435c1505797569d3e
---
M tests/phpunit/includes/TitleTest.php
M tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
2 files changed, 44 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/16/104016/1
diff --git a/tests/phpunit/includes/TitleTest.php
b/tests/phpunit/includes/TitleTest.php
index 58f0146..e71e0c0 100644
--- a/tests/phpunit/includes/TitleTest.php
+++ b/tests/phpunit/includes/TitleTest.php
@@ -40,6 +40,21 @@
* @todo This method should be split into 2 separate tests each with a
provider
*/
public function testSecureAndSplit() {
+ $this->setMwGlobals( array(
+ 'wgLocalInterwiki' => 'localtestiw',
+ 'wgHooks' => array(
+ 'InterwikiLoadPrefix' => array(
+ function ( $prefix, &$data ) {
+ if ( $prefix == 'localtestiw' )
{
+ $data = array( 'iw_url'
=> 'localtestiw' );
+ } elseif ( $prefix ==
'remotetestiw' ) {
+ $data = array( 'iw_url'
=> 'remotetestiw' );
+ }
+ return false;
+ }
+ )
+ )
+ ));
// Valid
foreach ( array(
'Sandbox',
@@ -49,6 +64,8 @@
'~',
'"',
'\'',
+ '#', //Do we want that?
+ '#anchor',
'Talk:Sandbox',
'Talk:Foo:Sandbox',
'File:Example.svg',
@@ -58,7 +75,16 @@
'A~~',
// Length is 256 total, but only title part matters
'Category:' . str_repeat( 'x', 248 ),
- str_repeat( 'x', 252 )
+ str_repeat( 'x', 252 ),
+ // interwiki prefix
+ 'localtestiw: #anchor',
+ 'localtestiw:foo',
+ 'localtestiw: foo # anchor',
+ 'localtestiw: Talk: Sandbox # anchor',
+ 'remotetestiw:',
+ 'removetestiw: #bar',
+ 'remotetestiw: Talk:',
+ 'remotetestiw: Talk: Foo'
) as $text ) {
$this->assertInstanceOf( 'Title', Title::newFromText(
$text ), "Valid: $text" );
}
@@ -107,7 +133,9 @@
// ':', // bug 54044
'Talk:',
'Category: ',
- 'Category: #bar'
+ 'Category: #bar',
+ 'localtestiw:',
+ 'localtestiw: Talk:'
) as $text ) {
$this->assertNull( Title::newFromText( $text ),
"Invalid: $text" );
}
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
index 4083564..ef036f5 100644
--- a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
+++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
@@ -67,6 +67,8 @@
'~',
'"',
'\'',
+ '#', //Do we want that?
+ '#anchor',
'Talk:Sandbox',
'Talk:Foo:Sandbox',
'File:Example.svg',
@@ -76,7 +78,16 @@
'A~~',
// Length is 256 total, but only title part matters
'Category:' + repeat( 'x', 248 ),
- repeat( 'x', 252 )
+ repeat( 'x', 252 ),
+ // interwiki prefix
+ 'localtestiw: #anchor',
+ 'localtestiw:foo',
+ 'localtestiw: foo # anchor',
+ 'localtestiw: Talk: Sandbox # anchor',
+ 'remotetestiw:',
+ 'removetestiw: #bar',
+ 'remotetestiw: Talk:',
+ 'remotetestiw: Talk: Foo'
],
invalid: [
'',
@@ -125,6 +136,8 @@
'Talk:',
'Category: ',
'Category: #bar'
+// 'localtestiw:',
+// 'localtestiw: Talk:'
]
};
--
To view, visit https://gerrit.wikimedia.org/r/104016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I407355295b65bc67eb171da435c1505797569d3e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits