Unset CaptchaStore instance before test

Caught while tests were running for core.

Fatal error:
Call to undefined method CaptchaSessionStore::clearAll() in
ConfirmEdit/tests/CaptchaAuthenticationRequestTest.php
on line 13

Change-Id: I3a9f5b315eb114cb12ea4071f8da9079f797fcf6
This commit is contained in:
addshore 2016-07-28 14:51:51 +01:00
parent d1ef7ab717
commit eedab34d3d
3 changed files with 9 additions and 0 deletions

View file

@ -53,6 +53,13 @@ abstract class CaptchaStore {
return self::$instance;
}
final public static function unsetInstanceForTests() {
if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
throw new MWException( 'Cannot unset ' . __CLASS__ . ' instance in operation.' );
}
self::$instance = null;
}
/**
* Protected constructor: no creating instances except through the factory method above
*/

View file

@ -10,6 +10,7 @@ class CaptchaAuthenticationRequestTest extends AuthenticationRequestTestCase {
'wgCaptchaClass' => 'SimpleCaptcha',
'wgCaptchaStorageClass' => CaptchaHashStore::class,
] );
CaptchaStore::unsetInstanceForTests();
CaptchaStore::get()->clearAll();
CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] );
}

View file

@ -21,6 +21,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase {
'wgCaptchaStorageClass' => CaptchaHashStore::class,
'wgMainCacheType' => __METHOD__,
] );
CaptchaStore::unsetInstanceForTests();
CaptchaStore::get()->clearAll();
ObjectCache::$instances[__METHOD__] = new HashBagOStuff();
}