PreferencesIntegrationTest: CA will fail on null User objects

`$this->createMock( User::class )` will return a mock User object
with all fields defaulting to null and this will fail when the
`onGetPreferences()` hook fires in CA since that gets consumed by
`getFormDescriptor()` in PreferencesFactory.

This patch changes the mock user object to a test user object and
this is fine because it's already an integration test.

Bug: T357854
Change-Id: I3d80fc1e59ff00a1a08def41c53d82bc093b6e00
This commit is contained in:
Derick Alangi 2024-02-19 13:11:26 +03:00
parent ada6d85fe6
commit bc193d41a7
No known key found for this signature in database
GPG key ID: 01D205B3F82BADDA

View file

@ -3,7 +3,6 @@
namespace MediaWiki\Extension\Math\Tests;
use MediaWiki\Title\Title;
use MediaWiki\User\User;
use MediaWikiIntegrationTestCase;
use RequestContext;
@ -26,7 +25,7 @@ class PreferencesIntegrationTest extends MediaWikiIntegrationTestCase {
$context->setTitle( Title::makeTitle( NS_MAIN, 'Dummy' ) );
$allPreferences = $this->getServiceContainer()
->getPreferencesFactory()
->getFormDescriptor( $this->createMock( User::class ), $context );
->getFormDescriptor( $this->getTestUser()->getUser(), $context );
$this->assertArrayHasKey( 'math', $allPreferences );
$mathPrefs = $allPreferences['math'];
$this->assertSame( 'radio', $mathPrefs['type'] );