suin/php-expose

Makes non-public properties and methods be testable to help your unit tests with PHPUnit.

Maintainers

👁 suin

Package info

github.com/suin/php-expose

pkg:composer/suin/php-expose

Statistics

Installs: 8 125

Dependents: 13

Suggesters: 0

Stars: 5

Open Issues: 0

1.0 2012-09-16 08:57 UTC

Requires

  • php: >=5.3.0

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT a168e3e0c088a84f251354c3289a98eea9f1c993

  • suin <suinyeze.woop@gmail.com>

phpunitunittestexposetestable

This package is auto-updated.

Last update: 2026-06-06 12:09:40 UTC


README

Expose makes non-public properties and methods be testable to help your unit tests with PHPUnit.

The build status of the current master branch is tracked by Travis CI: 👁 Build Status

<?php
use \Expose\Expose as e;

class Object
{
	private $_secret;
	protected $_protected;

	private function _hello($world = 'World')
	{
		return sprintf('Hello, %s', $world);
	}
}

$object = new Object();

// Expose non-public properties
e::expose($object)
	->attr('_secret', 'foo')
	->attr('_protected', 'bar');

// Call non-public method
$result = e::expose($object)->call('_hello', 'Suin');

Requirements

  • PHP 5.3 or later

Installation

Just git-clone or inntall via composer.

composer.json:

{
	"require": {
		"suin/php-expose": ">=1.0"
	}
}

Inclue vendor/autoload.php in your bootstrap.php of PHPUnit to load Expose components:

require_once 'vendor/autoload.php';

License

MIT License