1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- /**
- * Verifies that special page aliases are valid, with no slashes.
- *
- * @group Language
- * @group SpecialPageAliases
- * @group SystemTest
- * @group medium
- * @todo This should be a structure test
- *
- * @author Katie Filbert < aude.wiki@gmail.com >
- */
- class SpecialPageAliasTest extends MediaWikiTestCase {
- /**
- * @coversNothing
- * @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( null, 'mwfile' ) );
- $data = [];
- foreach ( $codes as $code ) {
- $specialPageAliases = $this->getSpecialPageAliases( $code );
- if ( $specialPageAliases !== [] ) {
- $data[] = [ $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 [];
- }
- }
|