Reorg: Move StubObject classes in includes to its own directory

Bug: T166010
Change-Id: Idcf0e9dc6e0841e4f132207bce0f96774dad898c
This commit is contained in:
Amir Sarabadani 2022-10-25 18:58:49 +02:00 committed by James D. Forrester
parent e65773e428
commit 0fff5089ba
39 changed files with 113 additions and 43 deletions

View file

@ -368,7 +368,7 @@ $wgAutoloadLocalClasses = [
'DeleteUserEmail' => __DIR__ . '/maintenance/deleteUserEmail.php',
'DeletedContribsPager' => __DIR__ . '/includes/specials/pagers/DeletedContribsPager.php',
'DependencyWrapper' => __DIR__ . '/includes/language/dependency/DependencyWrapper.php',
'DeprecatedGlobal' => __DIR__ . '/includes/DeprecatedGlobal.php',
'DeprecatedGlobal' => __DIR__ . '/includes/StubObject/DeprecatedGlobal.php',
'DeprecatedInterfaceFinder' => __DIR__ . '/maintenance/findDeprecated.php',
'DeprecationHelper' => __DIR__ . '/includes/debug/DeprecationHelper.php',
'DerivativeContext' => __DIR__ . '/includes/context/DerivativeContext.php',
@ -1603,9 +1603,9 @@ $wgAutoloadLocalClasses = [
'StringPrefixSearch' => __DIR__ . '/includes/search/StringPrefixSearch.php',
'StringUtils' => __DIR__ . '/includes/libs/StringUtils.php',
'StripState' => __DIR__ . '/includes/parser/StripState.php',
'StubGlobalUser' => __DIR__ . '/includes/StubGlobalUser.php',
'StubObject' => __DIR__ . '/includes/StubObject.php',
'StubUserLang' => __DIR__ . '/includes/StubUserLang.php',
'StubGlobalUser' => __DIR__ . '/includes/StubObject/StubGlobalUser.php',
'StubObject' => __DIR__ . '/includes/StubObject/StubObject.php',
'StubUserLang' => __DIR__ . '/includes/StubObject/StubUserLang.php',
'SubmitAction' => __DIR__ . '/includes/actions/SubmitAction.php',
'SubpageImportTitleFactory' => __DIR__ . '/includes/title/SubpageImportTitleFactory.php',
'SvgHandler' => __DIR__ . '/includes/media/SvgHandler.php',

View file

@ -29,6 +29,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\ProcOpenError;
use MediaWiki\ResourceLoader\ResourceLoader;
use MediaWiki\Shell\Shell;
use MediaWiki\StubObject\StubUserLang;
use MediaWiki\Utils\UrlUtils;
use Wikimedia\AtEase\AtEase;
use Wikimedia\ParamValidator\TypeDef\ExpiryDef;

View file

@ -64,6 +64,8 @@ use MediaWiki\Settings\SettingsBuilder;
use MediaWiki\Settings\Source\PhpSettingsSource;
use MediaWiki\Settings\Source\ReflectionSchemaSource;
use MediaWiki\Settings\WikiFarmSettingsLoader;
use MediaWiki\StubObject\StubGlobalUser;
use MediaWiki\StubObject\StubUserLang;
use Psr\Log\LoggerInterface;
use Wikimedia\RequestTimeout\RequestTimeout;

View file

@ -21,6 +21,7 @@
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubUserLang;
/**
* Generic operation result class

View file

@ -20,6 +20,8 @@
* @file
*/
namespace MediaWiki\StubObject;
/**
* Class to allow throwing wfDeprecated warnings
* when people use globals that we do not want them to.
@ -44,10 +46,10 @@ class DeprecatedGlobal extends StubObject {
* that gives the function that uses this object, since:
*
* 1 = this function ( _newObject )
* 2 = StubObject::_unstub
* 3 = StubObject::_call
* 4 = StubObject::__call
* 5 = DeprecatedGlobal::<method of global called>
* 2 = MediaWiki\StubObject\StubObject::_unstub
* 3 = MediaWiki\StubObject\StubObject::_call
* 4 = MediaWiki\StubObject\StubObject::__call
* 5 = MediaWiki\StubObject\DeprecatedGlobal::<method of global called>
* 6 = Actual function using the global.
* (the same applies to _get/__get or _set/__set instead of _call/__call)
*
@ -59,3 +61,5 @@ class DeprecatedGlobal extends StubObject {
return parent::_newObject();
}
}
class_alias( DeprecatedGlobal::class, 'DeprecatedGlobal' );

View file

@ -18,6 +18,11 @@
* @file
*/
namespace MediaWiki\StubObject;
use InvalidArgumentException;
use User;
/**
* Stub object for the global user ($wgUser) that makes it possible to change the
* relevant underlying object while still ensuring that deprecation warnings will
@ -47,17 +52,18 @@ class StubGlobalUser extends StubObject {
/**
* @return User
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _newObject() {
// Based on DeprecatedGlobal::_newObject
// Based on MediaWiki\StubObject\DeprecatedGlobal::_newObject
/*
* Put the caller offset for wfDeprecated as 6, as
* that gives the function that uses this object, since:
*
* 1 = this function ( _newObject )
* 2 = StubGlobalUser::_unstub
* 3 = StubObject::_call
* 4 = StubObject::__call
* 5 = StubGlobalUser::<method of global called>
* 2 = MediaWiki\StubObject\StubGlobalUser::_unstub
* 3 = MediaWiki\StubObject\StubObject::_call
* 4 = MediaWiki\StubObject\StubObject::__call
* 5 = MediaWiki\StubObject\StubGlobalUser::<method of global called>
* 6 = Actual function using the global.
* (the same applies to _get/__get or _set/__set instead of _call/__call)
*
@ -82,7 +88,7 @@ class StubGlobalUser extends StubObject {
global $wgUser;
self::$destructorDeprecationDisarmed = true;
// Supports StubGlobalUser parameter in case something fetched the existing value of
// Supports MediaWiki\StubObject\StubGlobalUser parameter in case something fetched the existing value of
// $wgUser, set it to something else, and now is trying to restore it
$realUser = self::getRealUser( $user );
$wgUser = new self( $realUser );
@ -90,8 +96,8 @@ class StubGlobalUser extends StubObject {
}
/**
* Get the relevant "real" user object based on either a User object or a StubGlobalUser
* wrapper. Bypasses deprecation notices from converting a StubGlobalUser to an actual
* Get the relevant "real" user object based on either a User object or a MediaWiki\StubObject\StubGlobalUser
* wrapper. Bypasses deprecation notices from converting a MediaWiki\StubObject\StubGlobalUser to an actual
* user, and does not change $wgUser.
*
* @param StubGlobalUser|User $globalUser
@ -104,8 +110,8 @@ class StubGlobalUser extends StubObject {
return $globalUser;
} else {
throw new InvalidArgumentException(
'$globalUser must be a User (or StubGlobalUser), got ' .
( is_object( $globalUser ) ? get_class( $globalUser ) : gettype( $globalUser ) )
'$globalUser must be a User (or MediaWiki\StubObject\StubGlobalUser), got ' .
( is_object( $globalUser ) ? get_class( $globalUser ) : gettype( $globalUser ) )
);
}
}
@ -116,7 +122,7 @@ class StubGlobalUser extends StubObject {
* This is public, for the convenience of external callers wishing to access
* properties, e.g. eval.php
*
* Overriding StubObject::_unstub because for some reason that thinks there is
* Overriding MediaWiki\StubObject\StubObject::_unstub because for some reason that thinks there is
* an unstub loop when trying to use the magic __set() logic, but there isn't
* any loop because _newObject() returns a specific instance of User rather
* than calling any methods that could then try to use $wgUser. The main difference
@ -128,6 +134,7 @@ class StubGlobalUser extends StubObject {
* who called this function.
* @return User The unstubbed version
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _unstub( $name = '_unstub', $level = 2 ) {
if ( !$GLOBALS[$this->global] instanceof self ) {
return $GLOBALS[$this->global]; // already unstubbed.
@ -146,3 +153,5 @@ class StubGlobalUser extends StubObject {
}
}
}
class_alias( StubGlobalUser::class, 'StubGlobalUser' );

View file

@ -23,6 +23,10 @@
*
* @file
*/
namespace MediaWiki\StubObject;
use MWException;
use Wikimedia\ObjectFactory\ObjectFactory;
/**
@ -42,7 +46,7 @@ use Wikimedia\ObjectFactory\ObjectFactory;
* another function, and the other function calls some method of the stub. The
* best way to avoid this is to make constructors as lightweight as possible,
* deferring any initialisation which depends on other modules. As a last
* resort, you can use StubObject::isRealObject() to break the loop, but as a
* resort, you can use MediaWiki\StubObject\StubObject::isRealObject() to break the loop, but as a
* general rule, the stub object mechanism should be transparent, and code
* which refers to it should be kept to a minimum.
*
@ -84,7 +88,7 @@ class StubObject {
* a infinite loop when unstubbing an object.
*
* @param object $obj Object to check.
* @return bool True if $obj is not an instance of StubObject class.
* @return bool True if $obj is not an instance of MediaWiki\StubObject\StubObject class.
*/
public static function isRealObject( $obj ) {
return is_object( $obj ) && !$obj instanceof self;
@ -115,6 +119,7 @@ class StubObject {
* @param array $args Arguments
* @return mixed
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _call( $name, $args ) {
$this->_unstub( $name, 5 );
return call_user_func_array( [ $GLOBALS[$this->global], $name ], $args );
@ -124,6 +129,7 @@ class StubObject {
* Create a new object to replace this stub object.
* @return object
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _newObject() {
$params = $this->factory
? [ 'factory' => $this->factory ]
@ -132,9 +138,9 @@ class StubObject {
// ObjectFactory::getObjectFromSpec accepts an array, not just a callable (phan bug)
// @phan-suppress-next-line PhanTypeInvalidCallableArraySize
return ObjectFactory::getObjectFromSpec( $params + [
'args' => $this->params,
'closure_expansion' => false,
] );
'args' => $this->params,
'closure_expansion' => false,
] );
}
/**
@ -155,6 +161,7 @@ class StubObject {
* @param string $name Name of the property to get
* @return mixed
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _get( $name ) {
$this->_unstub( "__get($name)", 5 );
return $GLOBALS[$this->global]->$name;
@ -177,6 +184,7 @@ class StubObject {
* @param string $name Name of the property to set
* @param mixed $value New property value
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _set( $name, $value ) {
$this->_unstub( "__set($name)", 5 );
$GLOBALS[$this->global]->$name = $value;
@ -205,6 +213,7 @@ class StubObject {
* @return object The unstubbed version of itself
* @throws MWException
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _unstub( $name = '_unstub', $level = 2 ) {
static $recursionLevel = 0;
@ -226,3 +235,5 @@ class StubObject {
}
}
}
class_alias( StubObject::class, 'StubObject' );

View file

@ -18,6 +18,11 @@
* @file
*/
namespace MediaWiki\StubObject;
use Language;
use RequestContext;
/**
* Stub object for the user language. Assigned to the $wgLang global.
*/
@ -30,7 +35,10 @@ class StubUserLang extends StubObject {
/**
* @return Language
*/
// phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
public function _newObject() {
return RequestContext::getMain()->getLanguage();
}
}
class_alias( StubUserLang::class, 'StubUserLang' );

View file

@ -34,6 +34,7 @@ use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageStoreRecord;
use MediaWiki\Page\ProperPageIdentity;
use MediaWiki\ResourceLoader\WikiModule;
use MediaWiki\StubObject\StubUserLang;
use Wikimedia\Assert\Assert;
use Wikimedia\Assert\PreconditionException;
use Wikimedia\Rdbms\IDatabase;

View file

@ -28,6 +28,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\ParamValidator\TypeDef\UserDef;
use MediaWiki\Rest\HeaderParser\Origin;
use MediaWiki\Session\SessionManager;
use MediaWiki\StubObject\StubGlobalUser;
use MediaWiki\User\UserRigorOptions;
use Wikimedia\AtEase\AtEase;
use Wikimedia\ParamValidator\ParamValidator;

View file

@ -39,6 +39,7 @@ use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\Revision\SlotRenderingProvider;
use MediaWiki\Search\ParserOutputSearchDataExtractor;
use MediaWiki\StubObject\StubObject;
use Wikimedia\Assert\Assert;
use Wikimedia\ScopedCallback;
@ -724,7 +725,7 @@ abstract class ContentHandler {
}
// Simplify hook handlers by only passing objects of one type, in case nothing
// else has unstubbed the StubUserLang object by now.
// else has unstubbed the MediaWiki\StubObject\StubUserLang object by now.
StubObject::unstub( $wgLang );
$this->getHookRunner()->onPageContentLanguage( $title, $pageLang, $wgLang );

View file

@ -27,6 +27,7 @@ use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Permissions\Authority;
use MediaWiki\Session\CsrfTokenSet;
use MediaWiki\StubObject\StubGlobalUser;
use Wikimedia\AtEase\AtEase;
use Wikimedia\IPUtils;
use Wikimedia\NonSerializable\NonSerializableTrait;

View file

@ -31,6 +31,7 @@ use MediaWiki\MainConfigNames;
use MediaWiki\MainConfigSchema;
use MediaWiki\MediaWikiServices;
use MediaWiki\Settings\SettingsBuilder;
use MediaWiki\StubObject\StubGlobalUser;
use Wikimedia\AtEase\AtEase;
/**

View file

@ -29,6 +29,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\StubObject\StubUserLang;
/**
* Base class for multi-variant language conversion.

View file

@ -29,9 +29,9 @@ use IuConverter;
use KkConverter;
use KuConverter;
use Language;
use MediaWiki\StubObject\StubUserLang;
use ShiConverter;
use SrConverter;
use StubUserLang;
use TgConverter;
use TlyConverter;
use TrivialLanguageConverter;
@ -146,7 +146,7 @@ class LanguageConverterFactory {
/**
* Returns Converter instance for given language object
*
* @param Language|StubUserLang $lang
* @param Language|\MediaWiki\StubObject\StubUserLang $lang
* @return ILanguageConverter
*/
private function instantiateConverter( $lang ): ILanguageConverter {

View file

@ -25,6 +25,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\Message\UserGroupMembershipParam;
use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageReferenceValue;
use MediaWiki\StubObject\StubUserLang;
/**
* The Message class deals with fetching and processing of interface message

View file

@ -32,6 +32,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageReferenceValue;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\StubObject\StubObject;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;
use Wikimedia\Rdbms\Database;

View file

@ -20,6 +20,7 @@
use MediaWiki\Linker\LinkTarget;
use MediaWiki\MediaWikiServices;
use MediaWiki\Page\PageReference;
use MediaWiki\StubObject\StubUserLang;
/**
* A trivial language converter.

View file

@ -18,6 +18,8 @@
* @file
*/
use MediaWiki\StubObject\StubUserLang;
/**
* Crimean Tatar (Qırımtatarca) converter routines.
*

View file

@ -25,6 +25,7 @@
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubUserLang;
use MediaWiki\User\UserIdentity;
/**

View file

@ -27,6 +27,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\Parser\ParserOutputFlags;
use MediaWiki\Revision\RevisionAccessException;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\StubObject\StubUserLang;
use Wikimedia\RemexHtml\Tokenizer\Attributes;
use Wikimedia\RemexHtml\Tokenizer\PlainAttributes;

View file

@ -42,6 +42,7 @@ use MediaWiki\Revision\RevisionAccessException;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\SpecialPage\SpecialPageFactory;
use MediaWiki\StubObject\StubUserLang;
use MediaWiki\Tidy\TidyDriverBase;
use MediaWiki\User\UserFactory;
use MediaWiki\User\UserIdentity;

View file

@ -25,6 +25,7 @@ use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\MutableRevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\StubObject\StubObject;
use MediaWiki\User\UserIdentity;
use Wikimedia\ScopedCallback;

View file

@ -29,6 +29,7 @@ use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\Session\SessionManager;
use MediaWiki\StubObject\StubGlobalUser;
use Wikimedia\ScopedCallback;
/**

View file

@ -25,6 +25,7 @@ use MediaWiki\MediaWikiServices;
use MediaWiki\Permissions\Authority;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\StubObject\StubGlobalUser;
require_once __DIR__ . '/Maintenance.php';

View file

@ -29,6 +29,7 @@
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubGlobalUser;
require_once __DIR__ . '/Maintenance.php';

View file

@ -25,6 +25,7 @@
require_once __DIR__ . '/Maintenance.php';
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubGlobalUser;
/**
* Maintenance script that deletes all pages in the MediaWiki namespace

View file

@ -20,6 +20,7 @@
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubGlobalUser;
require_once __DIR__ . '/Maintenance.php';

View file

@ -23,6 +23,7 @@
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\StubObject\StubGlobalUser;
require_once __DIR__ . '/Maintenance.php';

View file

@ -36,6 +36,7 @@ require_once __DIR__ . '/Maintenance.php';
use MediaWiki\MainConfigNames;
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubGlobalUser;
class ImportImages extends Maintenance {

View file

@ -22,6 +22,7 @@
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubGlobalUser;
require_once __DIR__ . '/Maintenance.php';

View file

@ -27,6 +27,7 @@
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubGlobalUser;
require_once __DIR__ . '/Maintenance.php';

View file

@ -22,6 +22,7 @@
*/
use MediaWiki\MediaWikiServices;
use MediaWiki\StubObject\StubGlobalUser;
use Wikimedia\TestingAccessWrapper;
$optionsWithoutArgs = [ 'verbose' ];

View file

@ -21,6 +21,8 @@
* @ingroup Maintenance
*/
use MediaWiki\StubObject\StubGlobalUser;
require_once __DIR__ . '/Maintenance.php';
class Undelete extends Maintenance {

View file

@ -33,6 +33,7 @@ use MediaWiki\Parser\ParserOutputFlags;
use MediaWiki\Revision\MutableRevisionRecord;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use MediaWiki\StubObject\StubGlobalUser;
use Psr\Log\NullLogger;
use Wikimedia\Assert\Assert;
use Wikimedia\Parsoid\Config\PageConfig;

View file

@ -2,6 +2,7 @@
use MediaWiki\MainConfigNames;
use MediaWiki\Permissions\Authority;
use MediaWiki\StubObject\StubGlobalUser;
use MediaWiki\Tests\Unit\Permissions\MockAuthorityTrait;
use Wikimedia\Rdbms\DBConnRef;
use Wikimedia\Rdbms\DBQueryError;
@ -105,10 +106,10 @@ class ApiMainTest extends ApiTestCase {
public function testSuppressedLogin() {
// Testing some logic that changes the global $wgUser
// ApiMain will be setting it to a StubGlobalUser object, it should already
// ApiMain will be setting it to a MediaWiki\StubObject\StubGlobalUser object, it should already
// be one but in case its a full User object we will wrap the comparisons
// in StubGlobalUser::getRealUser() which will return the inner User object
// for a StubGlobalUser, or the actual User object if given a user.
// in MediaWiki\StubObject\StubGlobalUser::getRealUser() which will return the inner User object
// for a MediaWiki\StubObject\StubGlobalUser, or the actual User object if given a user.
// phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser
global $wgUser;

View file

@ -20,13 +20,14 @@
*/
// phpcs:disable MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser
use MediaWiki\StubObject\StubGlobalUser;
/**
* Tests the StubGlobalUser, including magic support for __get() and __set()
* Tests the MediaWiki\StubObject\StubGlobalUser, including magic support for __get() and __set()
*
* @author DannyS712
*
* @covers \StubGlobalUser
* @covers \MediaWiki\StubObject\StubGlobalUser
*/
class StubGlobalUserTest extends MediaWikiIntegrationTestCase {
@ -68,7 +69,7 @@ class StubGlobalUserTest extends MediaWikiIntegrationTestCase {
public function testRealUser_exception() {
$this->expectException( InvalidArgumentException::class );
$this->expectExceptionMessage(
'$globalUser must be a User (or StubGlobalUser), got integer'
'$globalUser must be a User (or MediaWiki\StubObject\StubGlobalUser), got integer'
);
StubGlobalUser::getRealUser( 12345 );
}
@ -81,7 +82,7 @@ class StubGlobalUserTest extends MediaWikiIntegrationTestCase {
$this->assertInstanceOf(
StubGlobalUser::class,
$wgUser,
'Check: $wgUser should be a StubGlobalUser at the start of the test'
'Check: $wgUser should be a MediaWiki\StubObject\StubGlobalUser at the start of the test'
);
$this->assertSame(
12345,
@ -103,7 +104,7 @@ class StubGlobalUserTest extends MediaWikiIntegrationTestCase {
$this->assertInstanceOf(
StubGlobalUser::class,
$wgUser,
'Check: $wgUser should be a StubGlobalUser at the start of the test'
'Check: $wgUser should be a MediaWiki\StubObject\StubGlobalUser at the start of the test'
);
$this->assertSame(
12345,
@ -118,7 +119,7 @@ class StubGlobalUserTest extends MediaWikiIntegrationTestCase {
}
public function testSetMagic() {
// This test is why we need StubGlobalUser::_unstub to override StubObject::_unstub
// This test is why we need MediaWiki\StubObject\StubGlobalUser::_unstub to override MediaWiki\StubObject\StubObject::_unstub
// and not try to detect and throw exceptions in unstub loops - for some reason it
// thinks this creates a loop.
@ -129,7 +130,7 @@ class StubGlobalUserTest extends MediaWikiIntegrationTestCase {
$this->assertInstanceOf(
StubGlobalUser::class,
$wgUser,
'Check: $wgUser should be a StubGlobalUser at the start of the test'
'Check: $wgUser should be a MediaWiki\StubObject\StubGlobalUser at the start of the test'
);
$wgUser->mId = 2000;
$this->assertInstanceOf(

View file

@ -19,13 +19,15 @@
* @file
*/
use MediaWiki\StubObject\StubObject;
/**
* Testing the magic for __get(), __set(), and __call() for our
* example global, $wgDummy, which would be an instance
* of DemoStubbed but is wrapped in a StubObject
* of DemoStubbed but is wrapped in a MediaWiki\StubObject\StubObject
* @author DannyS712
*
* @covers \StubObject
* @covers \MediaWiki\StubObject\StubObject
*/
class StubObjectTest extends MediaWikiIntegrationTestCase {
@ -80,7 +82,7 @@ class StubObjectTest extends MediaWikiIntegrationTestCase {
}
public function testGetMagic() {
// StubObject::__get() returning DemoStubbed::$num
// MediaWiki\StubObject\StubObject::__get() returning DemoStubbed::$num
global $wgDummy;
$this->assertInstanceOf(
StubObject::class,
@ -100,7 +102,7 @@ class StubObjectTest extends MediaWikiIntegrationTestCase {
}
public function testGetMagic_virtual() {
// StubObject::__get() calling DemoStubbed::__get()
// MediaWiki\StubObject\StubObject::__get() calling DemoStubbed::__get()
global $wgDummy;
$this->assertInstanceOf(
StubObject::class,
@ -120,7 +122,7 @@ class StubObjectTest extends MediaWikiIntegrationTestCase {
}
public function testSetMagic() {
// StubObject::__set() changing DemoStubbed::$num
// MediaWiki\StubObject\StubObject::__set() changing DemoStubbed::$num
global $wgDummy;
$this->assertInstanceOf(
StubObject::class,
@ -141,7 +143,7 @@ class StubObjectTest extends MediaWikiIntegrationTestCase {
}
public function testSetMagic_virtual() {
// StubObject::__set() calling DemoStubbed::__set()
// MediaWiki\StubObject\StubObject::__set() calling DemoStubbed::__set()
global $wgDummy;
$this->assertInstanceOf(
StubObject::class,

View file

@ -18,6 +18,8 @@
* @file
*/
use MediaWiki\StubObject\DeprecatedGlobal;
/**
* @covers DeprecatedGlobal
*/