Update docs/hooks.txt for ShowSearchHitTitle
[mediawiki.git] / tests / phpunit / languages / SpecialPageAliasTest.php
blob4a7fed2a06bcc4e1179e65a323b333d4cf1c0618
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 = [];
32 foreach ( $codes as $code ) {
33 $specialPageAliases = $this->getSpecialPageAliases( $code );
35 if ( $specialPageAliases !== [] ) {
36 $data[] = [ $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 [];