PHPackages                             joomla/test - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. joomla/test

ActiveJoomla-package[Framework](/categories/framework)

joomla/test
===========

Joomla Test Helper Package

4.0.1(7mo ago)3275.3k↓23.2%620GPL-2.0-or-laterPHPPHP ^8.3.0CI passing

Since May 15Pushed 7mo ago11 watchersCompare

[ Source](https://github.com/joomla-framework/test)[ Packagist](https://packagist.org/packages/joomla/test)[ Docs](https://github.com/joomla-framework/test)[ RSS](/packages/joomla-test/feed)WikiDiscussions 3.x-dev Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (35)Used By (20)

The Test Package [![Build Status](https://github.com/joomla-framework/test/status.svg)](https://github.com/joomla-framework/test)
=================================================================================================================================

[](#the-test-package-)

[![Latest Stable Version](https://camo.githubusercontent.com/e93fb472c27e91e070caeb0f57fa3d1041245a590a7234c9e0160ee5f2e299a2/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f746573742f762f737461626c65)](https://packagist.org/packages/joomla/test)[![Total Downloads](https://camo.githubusercontent.com/03ab28fd7168600bafc9bb159797fa8e6ef2f6dddc74cfee77962959e218ece5/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f746573742f646f776e6c6f616473)](https://packagist.org/packages/joomla/test)[![Latest Unstable Version](https://camo.githubusercontent.com/39cadbd5b14a21f3b5ca7b903772e33c7895194c8496c9018a3d7ffedf32698b/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f746573742f762f756e737461626c65)](https://packagist.org/packages/joomla/test)[![License](https://camo.githubusercontent.com/fd067794029fdae57472412c3c9ecb7115acd8e1e9d9d2f3c12fecc66d6ab2c4/68747470733a2f2f706f7365722e707567782e6f72672f6a6f6f6d6c612f746573742f6c6963656e7365)](https://packagist.org/packages/joomla/test)

This package is a collection of tools that make some of the jobs of unit testing easier.

TestHelper
----------

[](#testhelper)

`Joomla\Test\TestHelper` is a static helper class that can be used to take some of the pain out of repetitive tasks whilst unit testing with PHPUnit.

### Mocking

[](#mocking)

There are two methods that help with PHPUnit mock objects.

#### `TestHelper::assignMockCallbacks`

[](#testhelperassignmockcallbacks)

This helper method provides an easy way to configure mock callbacks in bulk.

```
use Joomla\Test\TestHelper;

class FooTest extends \PHPUnit_Framework_TestCase
{
	public function testFoo()
	{
		// Create the mock.
		$mockFoo = $this->getMock(
			'Foo',
			// Methods array.
			array(),
			// Constructor arguments.
			array(),
			// Mock class name.
			'',
			// Call original constructor.
			false
		);

		$mockCallbacks = array(
			// 'Method Name' =>
			'method1' => array('\mockFoo', 'method1'),
			'method2' => array($this, 'mockMethod2'),
		);

		TestHelper::assignMockCallbacks($mockFoo, $this, $mockCallbacks);
	}

	public function mockMethod2($value)
	{
		return strtolower($value);
	}
}
```

#### `TestHelper::assignMockReturns`

[](#testhelperassignmockreturns)

This helper method provides an easy way to configure mock returns values in bulk.

```
use Joomla\Test\TestHelper;

class FooTest extends \PHPUnit_Framework_TestCase
{
	public function testFoo()
	{
		// Create the mock.
		$mockFoo = $this->getMock(
			'Foo',
			// Methods array.
			array(),
			// Constructor arguments.
			array(),
			// Mock class name.
			'',
			// Call original constructor.
			false
		);

		$mockReturns = array(
			// 'Method Name' => 'Canned return value'
			'method1' => 'canned result 1',
			'method2' => 'canned result 2',
			'method3' => 'canned result 3',
		);

		TestHelper::assignMockReturns($mockFoo, $this, $mockReturns);
	}
}
```

### Reflection

[](#reflection)

There are three methods that help with reflection.

#### `TestHelper::getValue`

[](#testhelpergetvalue)

The `TestHelper::getValue` method allows you to get the value of any protected or private property.

```
use Joomla\Test\TestHelper;

class FooTest extends \PHPUnit_Framework_TestCase
{
	public function testFoo()
	{
		$instance = new \Foo;

		// Get the value of a protected `bar` property.
		$value = TestHelper::getValue($instance, 'bar');
	}
}
```

This method should be used sparingly. It is usually more appropriate to use PHPunit's `assertAttribute*` methods.

#### `TestHelper::setValue`

[](#testhelpersetvalue)

The `TestHelper::setValue` method allows you to set the value of any protected or private property.

```
use Joomla\Test\TestHelper;

class FooTest extends \PHPUnit_Framework_TestCase
{
	public function testFoo()
	{
		$instance = new \Foo;

		// Set the value of a protected `bar` property.
		TestHelper::setValue($instance, 'bar', 'New Value');
	}
}
```

This method is useful for injecting values into an object for the purpose of testing getter methods.

#### `TestHelper::invoke`

[](#testhelperinvoke)

The `TestHelper::invoke` method allow you to invoke any protected or private method. After specifying the object and the method name, any remaining arguments are passed to the method being invoked.

```
use Joomla\Test\TestHelper;

class FooTest extends \PHPUnit_Framework_TestCase
{
	public function testFoo()
	{
		$instance = new \Foo;

		// Invoke the protected `bar` method.
		$value1 = TestHelper::invoke($instance, 'bar');

		// Invoke the protected `bar` method with arguments.
		$value2 = TestHelper::invoke($instance, 'bar', 'arg1', 'arg2');
	}
}
```

Installation via Composer
-------------------------

[](#installation-via-composer)

Add `"joomla/test": "~2.0"` to the require block in your composer.json and then run `composer install`.

```
{
	"require": {
		"joomla/test": "~2.0"
	}
}
```

Alternatively, you can simply run the following from the command line:

```
composer require joomla/test "~2.0"
```

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance65

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 53.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~151 days

Recently: every ~24 days

Total

31

Last Release

213d ago

Major Versions

1.3.1 → 2.0.0-beta2020-06-05

1.4.3 → 2.0.22022-08-15

2.0.2 → 3.0.02023-10-08

3.0.3 → 4.02025-07-23

3.0.4 → 4.0.12025-10-17

PHP version history (8 changes)1.0-beta2PHP &gt;=5.3.10

1.2.0PHP ^5.3.10|~7.0

2.0.0-betaPHP ^7.2.5

2.0.0-rcPHP ^7.2.5|^8.0

1.4.0PHP ^5.3.10|^7.0|^8.0

2.0.2PHP ^7.2.5|~8.0.0|~8.1.0

3.0.0PHP ^8.1.0

4.0PHP ^8.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/305a2164440014dcef9ac681c139fe5e8a1ce1d7a8c3b3cfb828497729a4c70e?d=identicon)[wilsonge](/maintainers/wilsonge)

---

Top Contributors

[![mbabker](https://avatars.githubusercontent.com/u/368545?v=4)](https://github.com/mbabker "mbabker (62 commits)")[![Hackwar](https://avatars.githubusercontent.com/u/313866?v=4)](https://github.com/Hackwar "Hackwar (19 commits)")[![dongilbert](https://avatars.githubusercontent.com/u/718028?v=4)](https://github.com/dongilbert "dongilbert (6 commits)")[![nibra](https://avatars.githubusercontent.com/u/827605?v=4)](https://github.com/nibra "nibra (5 commits)")[![wilsonge](https://avatars.githubusercontent.com/u/1986000?v=4)](https://github.com/wilsonge "wilsonge (4 commits)")[![ianmacl](https://avatars.githubusercontent.com/u/176534?v=4)](https://github.com/ianmacl "ianmacl (3 commits)")[![joomla-jenkins](https://avatars.githubusercontent.com/u/929228?v=4)](https://github.com/joomla-jenkins "joomla-jenkins (2 commits)")[![richard67](https://avatars.githubusercontent.com/u/7413183?v=4)](https://github.com/richard67 "richard67 (2 commits)")[![RobertDeutz](https://avatars.githubusercontent.com/u/43096773?v=4)](https://github.com/RobertDeutz "RobertDeutz (2 commits)")[![Achal-Aggarwal](https://avatars.githubusercontent.com/u/3330262?v=4)](https://github.com/Achal-Aggarwal "Achal-Aggarwal (2 commits)")[![photodude](https://avatars.githubusercontent.com/u/10253980?v=4)](https://github.com/photodude "photodude (1 commits)")[![rdeutz](https://avatars.githubusercontent.com/u/467356?v=4)](https://github.com/rdeutz "rdeutz (1 commits)")[![realityking](https://avatars.githubusercontent.com/u/628508?v=4)](https://github.com/realityking "realityking (1 commits)")[![PhilETaylor](https://avatars.githubusercontent.com/u/400092?v=4)](https://github.com/PhilETaylor "PhilETaylor (1 commits)")[![eddieajau](https://avatars.githubusercontent.com/u/700871?v=4)](https://github.com/eddieajau "eddieajau (1 commits)")[![brianteeman](https://avatars.githubusercontent.com/u/1296369?v=4)](https://github.com/brianteeman "brianteeman (1 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")[![heelc29](https://avatars.githubusercontent.com/u/66922325?v=4)](https://github.com/heelc29 "heelc29 (1 commits)")

---

Tags

joomlajoomla-frameworkmockingphpphpunitreflectionphpunitframeworkreflectionunit testjoomla

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/joomla-test/health.svg)

```
[![Health](https://phpackages.com/badges/joomla-test/health.svg)](https://phpackages.com/packages/joomla-test)
```

###  Alternatives

[joomla/filter

Joomla Filter Package

151.4M8](/packages/joomla-filter)[joomla/application

Joomla Application Package

23404.8k11](/packages/joomla-application)[joomla/http

Joomla HTTP Package

17674.4k12](/packages/joomla-http)[joomla/registry

Joomla Registry Package

16468.6k20](/packages/joomla-registry)[joomla/filesystem

Joomla Filesystem Package

12369.7k7](/packages/joomla-filesystem)[joomla/oauth2

Joomla OAuth2 Package

10303.1k2](/packages/joomla-oauth2)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
