public static function provideFormat() {
return [
- [ NS_MAIN, 'Foo_Bar', '', 'en', 'Foo Bar' ],
- [ NS_USER, 'Hansi_Maier', 'stuff_and_so_on', 'en', 'User:Hansi Maier#stuff and so on' ],
- [ false, 'Hansi_Maier', '', 'en', 'Hansi Maier' ],
+ [ NS_MAIN, 'Foo_Bar', '', '', 'en', 'Foo Bar' ],
+ [ NS_USER, 'Hansi_Maier', 'stuff_and_so_on', '', 'en', 'User:Hansi Maier#stuff and so on' ],
+ [ false, 'Hansi_Maier', '', '', 'en', 'Hansi Maier' ],
[
NS_USER_TALK,
'hansi__maier',
'',
+ '',
'en',
'User talk:hansi maier',
'User talk:Hansi maier'
// getGenderCache() provides a mock that considers first
// names ending in "a" to be female.
- [ NS_USER, 'Lisa_Müller', '', 'de', 'Benutzerin:Lisa Müller' ],
+ [ NS_USER, 'Lisa_Müller', '', '', 'de', 'Benutzerin:Lisa Müller' ],
+ [ NS_MAIN, 'FooBar', '', 'remotetestiw', 'en', 'remotetestiw:FooBar' ],
];
}
/**
* @dataProvider provideFormat
*/
- public function testFormat( $namespace, $text, $fragment, $lang, $expected, $normalized = null ) {
+ public function testFormat( $namespace, $text, $fragment, $interwiki, $lang, $expected,
+ $normalized = null
+ ) {
if ( $normalized === null ) {
$normalized = $expected;
}
$codec = $this->makeCodec( $lang );
- $actual = $codec->formatTitle( $namespace, $text, $fragment );
+ $actual = $codec->formatTitle( $namespace, $text, $fragment, $interwiki );
$this->assertEquals( $expected, $actual, 'formatted' );
$actual2 = $codec->formatTitle(
$parsed->getNamespace(),
$parsed->getText(),
- $parsed->getFragment()
+ $parsed->getFragment(),
+ $parsed->getInterwiki()
);
$this->assertEquals( $normalized, $actual2, 'normalized after round trip' );
// getGenderCache() provides a mock that considers first
// names ending in "a" to be female.
[ NS_USER, 'Lisa_Müller', '', 'de', 'Benutzerin:Lisa Müller' ],
+ [ 1000000, 'Invalid_namespace', '', 'en', ':Invalid namespace' ],
];
}
$this->assertEquals( $expected, $actual );
}
+ public static function provideGetPrefixedDBkey() {
+ return [
+ [ NS_MAIN, 'Foo_Bar', '', '', 'en', 'Foo_Bar' ],
+ [ NS_USER, 'Hansi_Maier', 'stuff_and_so_on', '', 'en', 'User:Hansi_Maier' ],
+
+ // No capitalization or normalization is applied while formatting!
+ [ NS_USER_TALK, 'hansi__maier', '', '', 'en', 'User_talk:hansi__maier' ],
+
+ // getGenderCache() provides a mock that considers first
+ // names ending in "a" to be female.
+ [ NS_USER, 'Lisa_Müller', '', '', 'de', 'Benutzerin:Lisa_Müller' ],
+
+ [ NS_MAIN, 'Remote_page', '', 'remotetestiw', 'en', 'remotetestiw:Remote_page' ],
+
+ // non-existent namespace
+ [ 10000000, 'Foobar', '', '', 'en', ':Foobar' ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideGetPrefixedDBkey
+ */
+ public function testGetPrefixedDBkey( $namespace, $dbkey, $fragment,
+ $interwiki, $lang, $expected
+ ) {
+ $codec = $this->makeCodec( $lang );
+ $title = new TitleValue( $namespace, $dbkey, $fragment, $interwiki );
+
+ $actual = $codec->getPrefixedDBkey( $title );
+
+ $this->assertEquals( $expected, $actual );
+ }
+
public static function provideGetFullText() {
return [
[ NS_MAIN, 'Foo_Bar', '', 'en', 'Foo Bar' ],
[ 'Talk:File:Foo.jpg' ],
[ 'Talk:localtestiw:Foo' ],
- [ 'remotetestiw:Foo' ],
[ '::1' ], // only valid in user namespace
[ 'User::x' ], // leading ":" in a user name is only valid of IPv6 addresses