* @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',
'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:',
+ 'remotetestiw: Talk: # anchor',
+ 'remotetestiw: #bar',
+ 'remotetestiw: Talk:',
+ 'remotetestiw: Talk: Foo'
) as $text ) {
$this->assertInstanceOf( 'Title', Title::newFromText( $text ), "Valid: $text" );
}
// Namespace prefix without actual title
'Talk:',
'Category: ',
- 'Category: #bar'
+ 'Category: #bar',
+ // interwiki prefix
+ 'localtestiw:',
+ 'localtestiw: Talk: # anchor',
+ 'localtestiw: Talk:'
) as $text ) {
$this->assertNull( Title::newFromText( $text ), "Invalid: $text" );
}