r112340 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112339‎ | r112340 | r112341 >
Date:18:49, 24 February 2012
Author:maxsem
Status:ok
Tags:
Comment:
Test that verifies uniqueness of query module prefixes
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/api/PrefixUniquenessTest.php (added) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/api/PrefixUniquenessTest.php
@@ -0,0 +1,24 @@
 2+<?php
 3+
 4+/**
 5+ * Checks that all API query modules, core and extensions, have unique prefixes
 6+ * @group API
 7+ */
 8+class PrefixUniquenessTest extends MediaWikiTestCase {
 9+ public function testPrefixes() {
 10+ $main = new ApiMain( new FauxRequest() );
 11+ $query = new ApiQuery( $main, 'foo', 'bar' );
 12+ $modules = $query->getModules();
 13+ $prefixes = array();
 14+
 15+ foreach ( $modules as $name => $class ) {
 16+ $module = new $class( $main, $name );
 17+ $prefix = $module->getModulePrefix();
 18+ if ( isset( $prefixes[$prefix] ) ) {
 19+ $this->fail( "Module prefix '{$prefix}' is shared between {$class} and {$prefixes[$prefix]}" );
 20+ }
 21+ $prefixes[$module->getModulePrefix()] = $class;
 22+ }
 23+ $this->assertTrue( true ); // dummy call to make this test non-incomplete
 24+ }
 25+}
Property changes on: trunk/phase3/tests/phpunit/includes/api/PrefixUniquenessTest.php
___________________________________________________________________
Added: svn:eol-style
126 + native

Status & tagging log