2017 © Pedro Peláez
 

library testing-access-wrapper

A simple helper class to access non-public elements of a class when testing.

image

wikimedia/testing-access-wrapper

A simple helper class to access non-public elements of a class when testing.

  • Saturday, July 28, 2018
  • by wikimedia
  • Repository
  • 12 Watchers
  • 0 Stars
  • 68,707 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

![Latest Stable Version] ![License], (*1)

Wikimedia Testing Access Wrapper

Testing Access Wrapper is a simple helper for writing unit tests which provides convenient shortcuts for using reflection to access non-public properties/methods., (*2)

The code was originally part of MediaWiki. See composer.json for a list of authors., (*3)

Usage

use Wikimedia\TestingAccessWrapper;

class NonPublic {
    protected $prop;
    protected const CONSTANT = 4;
    protected function func() {}
    protected static function staticFunc() {}
}

class NonPublicCtor {
    protected function __construct() {}
}

$object = new NonPublic();
// or:
// $object = TestingAccessWrapper::construct( NonPublicCtor::class );

$wrapper = TestingAccessWrapper::newFromObject( $object );
$classWrapper = TestingAccessWrapper::newFromClass( NonPublic::class );

$wrapper->prop = 'foo';
$wrapper->func();
$classWrapper->staticFunc();

$value = TestingAccessWrapper::constant( NonPublic::class, 'CONSTANT' );

Running tests

composer install
composer test

The Versions

28/07 2018

dev-master

9999999-dev https://www.mediawiki.org/wiki/testing-access-wrapper

A simple helper class to access non-public elements of a class when testing.

  Sources   Download

GPL-2.0+ GPL-2.0-or-later

The Requires

  • php >=5.5.9

 

The Development Requires

by Brad Jorsch
by Gergő Tisza
by Adam Roses Wight

19/04 2017

1.0.0

1.0.0.0 https://www.mediawiki.org/wiki/Testing-access-wrapper

A simple helper class to access non-public elements of a class when testing.

  Sources   Download

GPL-2.0+

The Requires

  • php >=5.3.0

 

The Development Requires

by Brad Jorsch
by Gergő Tisza
by Adam Roses Wight