Improve test coverage for ApiLogin.php
[lhc/web/wiklou.git] / tests / phpunit / includes / api / ApiLoginTest.php
index ed4d683..d382c83 100644 (file)
@@ -282,4 +282,20 @@ class ApiLoginTest extends ApiTestCase {
                $this->assertEquals( 'Success', $a );
        }
 
+       public function testLoginWithNoSameOriginSecurity() {
+               $this->setTemporaryHook( 'RequestHasSameOriginSecurity',
+                       function () {
+                               return false;
+                       }
+               );
+
+               $result = $this->doApiRequest( [
+                       'action' => 'login',
+               ] )[0]['login'];
+
+               $this->assertSame( [
+                       'result' => 'Aborted',
+                       'reason' => 'Cannot log in when the same-origin policy is not applied.',
+               ], $result );
+       }
 }