MediaWiki  1.28.0
TestingAccessWrapper Class Reference

Circumvent access restrictions on object internals. More...

Public Member Functions

 __call ($method, $args)
 
 __get ($name)
 
 __set ($name, $value)
 

Static Public Member Functions

static newFromClass ($className)
 Allow access to non-public static methods and properties of the class. More...
 
static newFromObject ($object)
 Return the same object, without access restrictions. More...
 

Public Attributes

mixed $object
 The object, or the class name for static-only access. More...
 

Private Member Functions

 getMethod ($name)
 Return a property and make it accessible. More...
 
 getProperty ($name)
 Return a property and make it accessible. More...
 
 isStatic ()
 

Detailed Description

Circumvent access restrictions on object internals.

This can be helpful for writing tests that can probe object internals, without having to modify the class under test to accomodate.

Wrap an object with private methods as follows: $title = TestingAccessWrapper::newFromObject( Title::newFromDBkey( $key ) );

You can access private and protected instance methods and variables: $formatter = $title->getTitleFormatter();

TODO:

  • Organize other helper classes in tests/testHelpers.inc into a directory.

Definition at line 17 of file TestingAccessWrapper.php.

Member Function Documentation

TestingAccessWrapper::__call (   $method,
  $args 
)

Definition at line 46 of file TestingAccessWrapper.php.

References $args, $object, getMethod(), and isStatic().

TestingAccessWrapper::__get (   $name)

Definition at line 67 of file TestingAccessWrapper.php.

References $name, getProperty(), and isStatic().

TestingAccessWrapper::__set (   $name,
  $value 
)

Definition at line 57 of file TestingAccessWrapper.php.

References $name, $value, getProperty(), and isStatic().

TestingAccessWrapper::getMethod (   $name)
private

Return a property and make it accessible.

Parameters
string$name
Returns
ReflectionMethod

Definition at line 86 of file TestingAccessWrapper.php.

References $name.

Referenced by __call().

TestingAccessWrapper::getProperty (   $name)
private

Return a property and make it accessible.

ReflectionClass::getProperty() fails if the private property is defined in a parent class. This works more like ReflectionClass::getMethod().

Parameters
string$name
Returns
ReflectionProperty
Exceptions
ReflectionException

Definition at line 103 of file TestingAccessWrapper.php.

References $name.

Referenced by __get(), and __set().

TestingAccessWrapper::isStatic ( )
private

Definition at line 77 of file TestingAccessWrapper.php.

Referenced by __call(), __get(), and __set().

static TestingAccessWrapper::newFromObject (   $object)
static

Return the same object, without access restrictions.

Definition at line 24 of file TestingAccessWrapper.php.

References $object.

Referenced by ApiMessageTest\compareMessages(), MediaWiki\Session\SessionBackendTest\getBackend(), MediaWiki\Session\TestUtils\getDummySession(), MediaWiki\Session\TestUtils\getDummySessionBackend(), MediaWiki\Auth\RememberMeAuthenticationRequestTest\getInstance(), MediaWiki\Auth\AuthManagerTest\getMockSessionProvider(), MediaWiki\Session\PHPSessionHandlerTest\getResetter(), MediaWiki\Auth\AuthManagerTest\initializeManager(), MessageBlobStoreTest\makeBlobStore(), MediaWikiTestCase\restoreLoggers(), MediaWikiTestCase\setLogger(), TestingAccessWrapperTest\setUp(), WANObjectCacheTest\setUp(), RedisBagOStuffTest\setUp(), SwiftFileBackendTest\setUp(), MediaWiki\Auth\AbstractAuthenticationProviderTest\testAbstractAuthenticationProvider(), MediaWiki\Session\SessionBackendTest\testAddData(), MediaWiki\Session\SessionTest\testArrayAccess(), FileBackendTest\testAsyncWrites(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testAuthentication(), MediaWiki\Session\SessionManagerTest\testBackendRegistration(), MediaWiki\Session\SessionProviderTest\testBasics(), MediaWiki\Session\CookieSessionProviderTest\testBasics(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest\testBeginLinkAttempt(), ApiLoginTest\testBotPassword(), UserTest\testCheckAndSetTouched(), CentralIdLookupTest\testCheckAudience(), ApiMainTest\testCheckConditionalRequestHeaders(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testCheckPasswordValidity(), MediaWiki\Session\SessionTest\testClear(), ApiMainTest\testConditionalRequestHeadersOutput(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testConfig(), MediaWiki\Auth\EmailNotificationSecondaryAuthenticationProviderTest\testConstructor(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testConstructor(), MediaWiki\Auth\CheckBlocksSecondaryAuthenticationProviderTest\testConstructor(), MediaWiki\Auth\ThrottlePreAuthenticationProviderTest\testConstructor(), MediaWiki\Session\SessionTest\testConstructor(), MediaWiki\Auth\ThrottlerTest\testConstructor(), MediaWiki\Session\CookieSessionProviderTest\testConstructor(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testConstructor(), MediaWiki\Session\SessionBackendTest\testConstructor(), MediaWiki\Session\BotPasswordSessionProviderTest\testConstructor(), MediaWiki\Session\SessionManagerTest\testConstructor(), TestingAccessWrapperTest\testConstructorException(), MediaWiki\Auth\ConfirmLinkSecondaryAuthenticationProviderTest\testContinueLinkAttempt(), MediaWiki\Session\CookieSessionProviderTest\testCookieData(), MediaWiki\Session\SessionTest\testDataAccess(), MediaWiki\Session\SessionBackendTest\testDelaySave(), MediaWiki\Session\SessionBackendTest\testDirty(), MediaWiki\Session\PHPSessionHandlerTest\testDisabled(), ApiDocumentationTest\testDocumentationExists(), MediaWiki\Session\PHPSessionHandlerTest\testEnableFlags(), HashBagOStuffTest\testExpire(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testFailResponse(), MediaWiki\Session\SessionProviderTest\testGetAllowedUserRights(), MediaWiki\Session\BotPasswordSessionProviderTest\testGetAllowedUserRights(), FileBackendTest\testGetContentType(), MediaWiki\Session\CookieSessionProviderTest\testGetCookie(), ResourceLoaderClientHtmlTest\testGetData(), MediaWiki\Session\SessionBackendTest\testGetData(), MediaWiki\Session\SessionManagerTest\testGetEmptySession(), MediaWiki\Auth\RememberMeAuthenticationRequestTest\testGetFieldInfo_2(), MediaWiki\Session\SessionManagerTest\testGetGlobalSession(), MediaWiki\Session\CookieSessionProviderTest\testGetLoginCookieExpiration(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetNewPasswordExpiry(), ApiBaseTest\testGetParameterFromSettings(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetPassword(), BotPasswordTest\testGetPassword(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetPasswordFactory(), ResourceLoaderWikiModuleTest\testGetPreloadedTitleInfo(), MediaWiki\Session\SessionManagerTest\testGetProviders(), MediaWiki\Session\SessionManagerTest\testGetSessionFromInfo(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testGetSessionIdFromCookie(), ResourceLoaderWikiModuleTest\testGetTitleInfo(), MediaWiki\Logger\Monolog\KafkaHandlerTest\testHandlesNullFormatterResult(), MediaWiki\Session\SessionProviderTest\testHashToSessionId(), MediaWiki\Session\PHPSessionHandlerTest\testInstall(), BotPasswordTest\testInvalidateAllPasswordsForUser(), MediaWiki\Session\SessionManagerTest\testLoadSessionInfoFromStore(), ContentHandlerSanityTest\testMakeEmptyContent(), MediaWiki\Session\TokenTest\testMatch(), MediaWiki\Logger\MonologSpiTest\testMergeConfig(), MediaWiki\Logger\Monolog\LineFormatterTest\testNormalizeExceptionNoTrace(), MediaWiki\Logger\Monolog\LineFormatterTest\testNormalizeExceptionTrace(), MediaWiki\Auth\ThrottlerTest\testNormalizeThrottleConditions(), MediaWiki\Session\SessionBackendTest\testPersist(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testPersistSession(), MediaWiki\Session\CookieSessionProviderTest\testPersistSession(), MediaWiki\Session\CookieSessionProviderTest\testPersistSessionWithHook(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testProviderChangeAuthenticationDataEmail(), CdnCacheUpdateTest\testPurgeMergeWeb(), FileBackendTest\testReadAffinity(), MediaWiki\Session\SessionBackendTest\testRenew(), MediaWiki\Session\SessionBackendTest\testResetId(), MediaWiki\Session\SessionBackendTest\testResetIdOfGlobalSession(), FileBackendTest\testSanitizeOpHeaders(), BotPasswordTest\testSave(), MediaWiki\Session\SessionBackendTest\testSave(), MediaWiki\Session\SessionTest\testSecrets(), MessageTest\testSerialization(), MediaWiki\Session\PHPSessionHandlerTest\testSessionHandling(), MediaWiki\Session\SessionBackendTest\testSessionStuff(), MediaWiki\Session\CookieSessionProviderTest\testSetLoggedOutCookie(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), MediaWiki\Session\SessionBackendTest\testSetProviderMetadata(), MediaWiki\Session\SessionManagerTest\testShutdown(), MediaWiki\Auth\AuthManagerTest\testSingleton(), MediaWiki\Session\SessionBackendTest\testTakeOverGlobalSession(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\testTestUserCanAuthenticate(), MediaWiki\Session\SessionTest\testTokens(), MediaWiki\Session\TokenTest\testToStringAtTimestamp(), MediaWiki\Auth\ResetPasswordSecondaryAuthenticationProviderTest\testTryReset(), MediaWiki\Session\SessionBackendTest\testUnpersist(), MediaWiki\Session\SessionBackendTest\testUnpersistOfGlobalSession(), MediaWiki\Session\ImmutableSessionProviderWithCookieTest\testUnpersistSession(), UserTest\testUserGetRightsHooks(), OutputPageTest\testVaryHeaders(), and MediaWiki\Session\PHPSessionHandlerTest\testWrongInstance().

Member Data Documentation

mixed TestingAccessWrapper::$object

The object, or the class name for static-only access.

Definition at line 19 of file TestingAccessWrapper.php.

Referenced by __call(), and newFromObject().


The documentation for this class was generated from the following file: