X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiMainTest.php;h=7a03f7d27c8a40c31ae37ad6474ca3341232e3f1;hb=08611d0aef02e031a7e6f556d42786c76d8b3a60;hp=4bf6debed4e9972eb00b4948690c54c207834764;hpb=30e009794bacc2e3138c372e6ddf876dca2d4a9c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiMainTest.php b/tests/phpunit/includes/api/ApiMainTest.php index 4bf6debed4..7a03f7d27c 100644 --- a/tests/phpunit/includes/api/ApiMainTest.php +++ b/tests/phpunit/includes/api/ApiMainTest.php @@ -2,7 +2,6 @@ /** * @group API - * @group Database * @group medium * * @covers ApiMain @@ -23,20 +22,12 @@ class ApiMainTest extends ApiTestCase { } public static function provideAssert() { - $anon = new User(); - $bot = new User(); - $bot->setName( 'Bot' ); - $bot->addToDatabase(); - $bot->addGroup( 'bot' ); - $user = new User(); - $user->setName( 'User' ); - $user->addToDatabase(); return array( - array( $anon, 'user', 'assertuserfailed' ), - array( $user, 'user', false ), - array( $user, 'bot', 'assertbotfailed' ), - array( $bot, 'user', false ), - array( $bot, 'bot', false ), + array( false, array(), 'user', 'assertuserfailed' ), + array( true, array(), 'user', false ), + array( true, array(), 'bot', 'assertbotfailed' ), + array( true, array( 'bot' ), 'user', false ), + array( true, array( 'bot' ), 'bot', false ), ); } @@ -45,11 +36,17 @@ class ApiMainTest extends ApiTestCase { * * @covers ApiMain::checkAsserts * @dataProvider provideAssert - * @param User $user + * @param bool $registered + * @param array $rights * @param string $assert * @param string|bool $error False if no error expected */ - public function testAssert( $user, $assert, $error ) { + public function testAssert( $registered, $rights, $assert, $error ) { + $user = new User(); + if ( $registered ) { + $user->setId( 1 ); + } + $user->mRights = $rights; try { $this->doApiRequest( array( 'action' => 'query', @@ -61,4 +58,25 @@ class ApiMainTest extends ApiTestCase { } } + /** + * Test if all classes in the main module manager exists + */ + public function testClassNamesInModuleManager() { + global $wgAutoloadLocalClasses, $wgAutoloadClasses; + + // wgAutoloadLocalClasses has precedence, just like in includes/AutoLoader.php + $classes = $wgAutoloadLocalClasses + $wgAutoloadClasses; + + $api = new ApiMain( + new FauxRequest( array( 'action' => 'query', 'meta' => 'siteinfo' ) ) + ); + $modules = $api->getModuleManager()->getNamesWithClasses(); + foreach( $modules as $name => $class ) { + $this->assertArrayHasKey( + $class, + $classes, + 'Class ' . $class . ' for api module ' . $name . ' not in autoloader (with exact case)' + ); + } + } }