Import: Handle uploads with sha1 starting with 0 properly
[mediawiki.git] / tests / phpunit / languages / SpecialPageAliasTest.php
bloba6d9d2700f714240aa7b5b9b8fabc8f652098dde
1 <?php
3 /**
4 * Verifies that special page aliases are valid, with no slashes.
6 * @group Language
7 * @group SpecialPageAliases
8 * @group SystemTest
9 * @group medium
11 * @author Katie Filbert < aude.wiki@gmail.com >
13 class SpecialPageAliasTest extends MediaWikiTestCase {
15 /**
16 * @dataProvider validSpecialPageAliasesProvider
18 public function testValidSpecialPageAliases( $code, $specialPageAliases ) {
19 foreach ( $specialPageAliases as $specialPage => $aliases ) {
20 foreach ( $aliases as $alias ) {
21 $msg = "$specialPage alias '$alias' in $code is valid with no slashes";
22 $this->assertRegExp( '/^[^\/]*$/', $msg );
27 public function validSpecialPageAliasesProvider() {
28 $codes = array_keys( Language::fetchLanguageNames( 'mwfile' ) );
30 $data = array();
32 foreach ( $codes as $code ) {
33 $specialPageAliases = $this->getSpecialPageAliases( $code );
35 if ( $specialPageAliases !== array() ) {
36 $data[] = array( $code, $specialPageAliases );
40 return $data;
43 /**
44 * @param string $code
46 * @return array
48 protected function getSpecialPageAliases( $code ) {
49 $file = Language::getMessagesFileName( $code );
51 if ( is_readable( $file ) ) {
52 include $file;
54 if ( isset( $specialPageAliases ) && $specialPageAliases !== null ) {
55 return $specialPageAliases;
59 return array();