Fix ApiCreateAccountTest for $wgEnableEmail = false;
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 13 Jan 2013 10:10:55 +0000 (11:10 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Sun, 13 Jan 2013 10:10:55 +0000 (11:10 +0100)
1) ApiCreateAccountTest::testInvalidEmail
Failed asserting that exception of type "UsageException" is thrown.

Also explicit log out the user

Change-Id: I1d90c2b78bbcef494dc91822feeba37eebb8ca20

tests/phpunit/includes/api/ApiAccountCreationTest.php

index a764e9d..8eb8f9c 100644 (file)
@@ -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',
                ) );
        }
 }