diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-04-01 06:11:44 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-04-01 06:11:44 +0200 |
commit | 14f74d141ab5580688bfd46d2f74c026e43ed967 (patch) | |
tree | 081b7cbfc4d246ecc42831978d080331267cf57c /tests/phpunit/languages/SpecialPageAliasTest.php | |
parent | 4a953b6bfda28604979feb9cfbb58974d13b84bb (diff) |
Update to MediaWiki 1.24.2
Diffstat (limited to 'tests/phpunit/languages/SpecialPageAliasTest.php')
-rw-r--r-- | tests/phpunit/languages/SpecialPageAliasTest.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/phpunit/languages/SpecialPageAliasTest.php b/tests/phpunit/languages/SpecialPageAliasTest.php new file mode 100644 index 00000000..f6d6bc96 --- /dev/null +++ b/tests/phpunit/languages/SpecialPageAliasTest.php @@ -0,0 +1,63 @@ +<?php + +/** + * Verifies that special page aliases are valid, with no slashes. + * + * @group Language + * @group SpecialPageAliases + * @group SystemTest + * @group medium + * + * @licence GNU GPL v2+ + * @author Katie Filbert < aude.wiki@gmail.com > + */ +class SpecialPageAliasTest extends MediaWikiTestCase { + + /** + * @dataProvider validSpecialPageAliasesProvider + */ + public function testValidSpecialPageAliases( $code, $specialPageAliases ) { + foreach ( $specialPageAliases as $specialPage => $aliases ) { + foreach ( $aliases as $alias ) { + $msg = "$specialPage alias '$alias' in $code is valid with no slashes"; + $this->assertRegExp( '/^[^\/]*$/', $msg ); + } + } + } + + public function validSpecialPageAliasesProvider() { + $codes = array_keys( Language::fetchLanguageNames( 'mwfile' ) ); + + $data = array(); + + foreach ( $codes as $code ) { + $specialPageAliases = $this->getSpecialPageAliases( $code ); + + if ( $specialPageAliases !== array() ) { + $data[] = array( $code, $specialPageAliases ); + } + } + + return $data; + } + + /** + * @param string $code + * + * @return array + */ + protected function getSpecialPageAliases( $code ) { + $file = Language::getMessagesFileName( $code ); + + if ( is_readable( $file ) ) { + include $file; + + if ( isset( $specialPageAliases ) && $specialPageAliases !== null ) { + return $specialPageAliases; + } + } + + return array(); + } + +} |