From b74fac899e593b91ea1d685b9e8187bfa5cef02a Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 13 Jan 2013 11:10:55 +0100 Subject: [PATCH] Fix ApiCreateAccountTest for $wgEnableEmail = false; 1) ApiCreateAccountTest::testInvalidEmail Failed asserting that exception of type "UsageException" is thrown. Also explicit log out the user Change-Id: I1d90c2b78bbcef494dc91822feeba37eebb8ca20 --- .../includes/api/ApiAccountCreationTest.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/includes/api/ApiAccountCreationTest.php b/tests/phpunit/includes/api/ApiAccountCreationTest.php index a764e9ddd9..8eb8f9cc3f 100644 --- a/tests/phpunit/includes/api/ApiAccountCreationTest.php +++ b/tests/phpunit/includes/api/ApiAccountCreationTest.php @@ -31,7 +31,7 @@ class ApiCreateAccountTest extends ApiTestCase { 'action' => 'createaccount', 'name' => 'Apitestnew', 'password' => $password, - 'email' => 'test@example.com', + 'email' => 'test@domain.test', 'realname' => 'Test Name' ) ); @@ -88,6 +88,13 @@ class ApiCreateAccountTest extends ApiTestCase { $a = $result['login']['result']; $this->assertEquals( 'Success', $a ); + + // log out to destroy the session + $ret = $this->doApiRequest( array( + 'action' => 'logout', + ), $ret[2] + ); + $this->assertEquals( array(), $ret[0] ); } /** @@ -133,12 +140,16 @@ class ApiCreateAccountTest extends ApiTestCase { * @expectedException UsageException */ function testInvalidEmail() { + global $wgEnableEmail; + if( !$wgEnableEmail ) { + $this->markTestSkipped( 'email is not enabled, so createaccount does not check it' ); + } $this->doApiRequest( array( 'action' => 'createaccount', 'name' => 'Test User', 'token' => LoginForm::getCreateaccountToken(), 'password' => 'password', - 'email' => 'sjlfsjklj', + 'email' => 'invalid', ) ); } } -- 2.20.1