Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/108291
Change subject: Add tests for API's assert={user|bot}
......................................................................
Add tests for API's assert={user|bot}
Change-Id: I5bff0adf11bccef137d59c05edae45d774596994
---
M tests/phpunit/includes/api/ApiMainTest.php
1 file changed, 37 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/91/108291/1
diff --git a/tests/phpunit/includes/api/ApiMainTest.php
b/tests/phpunit/includes/api/ApiMainTest.php
index 4ed5aa9..5c2a9fc 100644
--- a/tests/phpunit/includes/api/ApiMainTest.php
+++ b/tests/phpunit/includes/api/ApiMainTest.php
@@ -30,4 +30,41 @@
$this->assertThat( $sxe, $this->isInstanceOf(
"SimpleXMLElement" ) );
}
+ public static function provideAssert() {
+ $anon = new User();
+ $bot = new User();
+ $bot->setName( 'Bot' );
+ $bot->addToDatabase();
+ $bot->addGroup( 'bot' );
+ $user = self::$users['sysop']->user; // Not a bot
+ return array(
+ array( $anon, 'user', 'assertuserfailed' ),
+ array( $user, 'user', false ),
+ array( $user, 'bot', 'assertbotfailed' ),
+ array( $bot, 'user', false ),
+ array( $bot, 'bot', false ),
+ );
+ }
+
+ /**
+ * Tests the assert={user|bot} functionality
+ *
+ * @covers ApiMain::checkAsserts
+ * @dataProvider provideAssert
+ * @param User $user
+ * @param string $assert
+ * @param string|bool $error false if no error expected
+ */
+ public function testAssert( $user, $assert, $error ) {
+ try {
+ $this->doApiRequest( array(
+ 'action' => 'query',
+ 'assert' => $assert,
+ ), null, null, $user );
+ $this->assertFalse( $error ); // That no error was
expected
+ } catch ( UsageException $e ) {
+ $this->assertEquals( $e->getCodeString(), $error );
+ }
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/108291
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5bff0adf11bccef137d59c05edae45d774596994
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits