diff --git a/tests/phpunit/CaptchaPreAuthenticationProviderTest.php b/tests/phpunit/CaptchaPreAuthenticationProviderTest.php index c6cbf0823..a1a6843d4 100644 --- a/tests/phpunit/CaptchaPreAuthenticationProviderTest.php +++ b/tests/phpunit/CaptchaPreAuthenticationProviderTest.php @@ -36,8 +36,10 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiIntegrationTestCase public function tearDown(): void { parent::tearDown(); + /** @var Hooks $req */ + $req = TestingAccessWrapper::newFromClass( Hooks::class ); // make sure $wgCaptcha resets between tests - TestingAccessWrapper::newFromClass( Hooks::class )->instanceCreated = false; + $req->instanceCreated = false; } /** @@ -102,10 +104,12 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiIntegrationTestCase [ 'username' => 'Foo' ] ); $this->assertCount( 1, $reqs ); - $this->assertInstanceOf( CaptchaAuthenticationRequest::class, $reqs[0] ); + /** @var CaptchaAuthenticationRequest $req */ + $req = $reqs[0]; + $this->assertInstanceOf( CaptchaAuthenticationRequest::class, $req ); - $id = $reqs[0]->captchaId; - $data = TestingAccessWrapper::newFromObject( $reqs[0] )->captchaData; + $id = $req->captchaId; + $data = $req->captchaData; $this->assertEquals( $captcha->retrieveCaptcha( $id ), $data + [ 'index' => $id ] ); } @@ -241,6 +245,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiIntegrationTestCase ); $provider = new CaptchaPreAuthenticationProvider(); $this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() ); + /** @var CaptchaPreAuthenticationProvider $providerAccess */ $providerAccess = TestingAccessWrapper::newFromObject( $provider ); $disablePingLimiter = false; diff --git a/tests/phpunit/SimpleCaptcha/CaptchaTest.php b/tests/phpunit/SimpleCaptcha/CaptchaTest.php index ef2c540eb..a61b72c10 100644 --- a/tests/phpunit/SimpleCaptcha/CaptchaTest.php +++ b/tests/phpunit/SimpleCaptcha/CaptchaTest.php @@ -171,10 +171,10 @@ class CaptchaTest extends MediaWikiIntegrationTestCase { 'edit' => true, ] ); $testObject = new SimpleCaptcha(); - /** @var SimpleCaptcha|TestingAccessWrapper $wrapper */ + /** @var SimpleCaptcha $wrapper */ $wrapper = TestingAccessWrapper::newFromObject( $testObject ); $wrapper->captchaSolved = true; - $this->assertFalse( $wrapper->triggersCaptcha( 'edit' ), 'CAPTCHA is not triggered if already solved' ); + $this->assertFalse( $testObject->triggersCaptcha( 'edit' ), 'CAPTCHA is not triggered if already solved' ); } public function testForceShowCaptcha() { @@ -182,12 +182,10 @@ class CaptchaTest extends MediaWikiIntegrationTestCase { 'edit' => false, ] ); $testObject = new SimpleCaptcha(); - /** @var SimpleCaptcha|TestingAccessWrapper $wrapper */ - $wrapper = TestingAccessWrapper::newFromObject( $testObject ); $this->assertFalse( - $wrapper->triggersCaptcha( 'edit' ), 'CAPTCHA is not triggered by edit action in this configuration' + $testObject->triggersCaptcha( 'edit' ), 'CAPTCHA is not triggered by edit action in this configuration' ); - $wrapper->setForceShowCaptcha( true ); - $this->assertTrue( $wrapper->triggersCaptcha( 'edit' ), 'Force showing a CAPTCHA if flag is set' ); + $testObject->setForceShowCaptcha( true ); + $this->assertTrue( $testObject->triggersCaptcha( 'edit' ), 'Force showing a CAPTCHA if flag is set' ); } }