From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- tests/phpunit/includes/TestingAccessWrapper.php | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/phpunit/includes/TestingAccessWrapper.php (limited to 'tests/phpunit/includes/TestingAccessWrapper.php') diff --git a/tests/phpunit/includes/TestingAccessWrapper.php b/tests/phpunit/includes/TestingAccessWrapper.php new file mode 100644 index 00000000..84c0f9b5 --- /dev/null +++ b/tests/phpunit/includes/TestingAccessWrapper.php @@ -0,0 +1,50 @@ +getTitleFormatter(); + * + * TODO: + * - Provide access to static methods and properties. + * - Organize other helper classes in tests/testHelpers.inc into a directory. + */ +class TestingAccessWrapper { + public $object; + + /** + * Return the same object, without access restrictions. + */ + public static function newFromObject( $object ) { + $wrapper = new TestingAccessWrapper(); + $wrapper->object = $object; + return $wrapper; + } + + public function __call( $method, $args ) { + $classReflection = new ReflectionClass( $this->object ); + $methodReflection = $classReflection->getMethod( $method ); + $methodReflection->setAccessible( true ); + return $methodReflection->invokeArgs( $this->object, $args ); + } + + public function __set( $name, $value ) { + $classReflection = new ReflectionClass( $this->object ); + $propertyReflection = $classReflection->getProperty( $name ); + $propertyReflection->setAccessible( true ); + $propertyReflection->setValue( $this->object, $value ); + } + + public function __get( $name ) { + $classReflection = new ReflectionClass( $this->object ); + $propertyReflection = $classReflection->getProperty( $name ); + $propertyReflection->setAccessible( true ); + return $propertyReflection->getValue( $this->object ); + } +} -- cgit v1.2.3-54-g00ecf