X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiMainTest.php;h=c111949d2fae4dfb6276c4a1c4b89fe7e5e1426b;hb=dcdb8e463e3b2be121c61c91df13ea36d270a602;hp=334e3b88fb48290064d089f0177d87bfad7d6b12;hpb=f826f2f5f6facdce2c92dcb9e70bb0cf20ff9db0;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/api/ApiMainTest.php b/tests/phpunit/includes/api/ApiMainTest.php index 334e3b88fb..c111949d2f 100644 --- a/tests/phpunit/includes/api/ApiMainTest.php +++ b/tests/phpunit/includes/api/ApiMainTest.php @@ -58,6 +58,29 @@ class ApiMainTest extends ApiTestCase { } } + /** + * Tests the assertuser= functionality + * + * @covers ApiMain::checkAsserts + */ + public function testAssertUser() { + $user = $this->getTestUser()->getUser(); + $this->doApiRequest( [ + 'action' => 'query', + 'assertuser' => $user->getName(), + ], null, null, $user ); + + try { + $this->doApiRequest( [ + 'action' => 'query', + 'assertuser' => $user->getName() . 'X', + ], null, null, $user ); + $this->fail( 'Expected exception not thrown' ); + } catch ( UsageException $e ) { + $this->assertEquals( $e->getCodeString(), 'assertnameduserfailed' ); + } + } + /** * Test if all classes in the main module manager exists */