PHPackages                             rafael.moran/uitest - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. rafael.moran/uitest

ActiveLibrary[Testing &amp; Quality](/categories/testing)

rafael.moran/uitest
===================

Unit and Integration testing package

v1.1(3y ago)052MITPHPPHP &gt;=7.2

Since Sep 10Pushed 3y ago2 watchersCompare

[ Source](https://github.com/ralphmoran/UITest)[ Packagist](https://packagist.org/packages/rafael.moran/uitest)[ Docs](https://github.com/ralphmoran/UITest)[ RSS](/packages/rafaelmoran-uitest/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

ralphmoran/uitest
=================

[](#ralphmoranuitest)

 A lightweight Unit and Integration(?) testing tool

 [![Source Code](https://camo.githubusercontent.com/0662ef521f7f1132a71855e594cec1dc356c401aabcae0bd3a59ea4982a4b823/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f536f757263652d72616c70686d6f72616e2f7569746573742d6f72616e6765)](https://github.com/ralphmoran/UITest) [![Download Package](https://camo.githubusercontent.com/653e4d1696ab0cc62745632f38bffc23b6987f001f9bd416bb1c6f726cb27c9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d76312e302d626c7565)](https://packagist.org/packages/rafael.moran/uitest) [![PHP Programming Language](https://camo.githubusercontent.com/f5e29b5cd17a3b41c4a9e5907cf685ff9664c95b3d44355bec0c43f1171607f2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d76372e325e2d626c7565)](https://php.net) [![Read License](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

UITesting
=========

[](#uitesting)

UITesting is an extremely light tool for Unit and (?)Integration testing.

Installation
------------

[](#installation)

.env file

Copy and paste the next ENV variables into your .env file. In order to avoid namespace conflits, customize your own namespace:

```
PATH_TESTS=tests
TEST_CASE_TEMPLATE=vendor/rafael.moran/uitest/src/UITestCaseTemplate.tpl
TEST_NAMESPACE=\UITesting\Tests
BASE_DIRNAME=
TEST_CASE_PREFIX=TestCase_

```

Create a new PHP file in your root directory, call it whatever you want, e.i.: `run-tests.php`, then add a new script in `scripts` section within `composer.json` using the new PHP filename:

```
...
"scripts": {
        "uitest" : "php ./run-tests.php",
        "uimaker" : "php vendor/rafael.moran/uitest/uimaker"
	}
...

```

You can execute your new command like:

```
$ composer uitest

```

Or you can use the REPL like:

```
$ composer uimaker -- -n=ClassNameX

```

Creating a UITester instance
----------------------------

[](#creating-a-uitester-instance)

Use the package like another PHP one:

```
// file: run-tests.php (you can pick whatever filename you want)
require_once 'vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();

// Entities to test
include __DIR__ . '/examples/functions.php';
include __DIR__ . '/examples/classes/Car.php';
include __DIR__ . '/examples/classes/AirPlane.php';

// Use case
$tester = new \RafaelMoran\UITest\UITester(['verbose' => true]); // set to false to not display details

// Run all tests
$tester->all();
```

Usage: How to create a UITester
-------------------------------

[](#usage-how-to-create-a-uitester)

```
use RafaelMoran\UITest\UITester;

// Use case
$tester = new UITester(); // It runs all test from $_ENV['PATH_TESTS'], results are not displayed.

// Or

// It's run all tests from `/another/real/weird/path/`
$tester = new UITester([
						"path" => "/another/real/weird/path/",
						"verbose" => true,
						// Or...
						"v" => true,
					]);
```

Run all tests
-------------

[](#run-all-tests)

```
/*
 * It runs all test cases from the default test folder `/tests/`
 * and display in detail all assertions statuses.
 */
$tester->all();

// ...

/**
 * It runs all test cases from the default test folder `/another/test/folder/`
 * and display in detail all assertions statuses.
 */
$tester->all("/another/test/folder/");
```

Run only specific tests
-----------------------

[](#run-only-specific-tests)

```
/**
 * It runs only `CarTest_518135355` from the default test folder `/tests/`
 * and display in detail all assertions statuses.
 */
$tester->only('CarTest_518135355')
		->outputTestResults();

// ...

/**
 * It runs only `CarTest_518135355` and `GetRandomStrTest_1218383454` test cases
 * from the default test folder `/tests/` and display in detail
 * all assertions statuses.
 */
$tester->only([
		'CarTest_518135355',
		'GetRandomStrTest_1218383454'
	])
	->outputTestResults();

// ...

/**
 * It runs only `CarTest_518135355` from the default test folder
 * `/another/real/weird/path/` and display in detail all assertions statuses.
 */
$tester->setPath('/another/real/weird/path/')
	->only('CarTest_518135355')
	->outputTestResults();
```

Usage: How to create a UITestCase
---------------------------------

[](#usage-how-to-create-a-uitestcase)

All your test cases must extend from the abstract class `UITestCase` and all tests/methods must start with `test_` and return void.

There is a folder named `/tests/` where all your test cases will be saved by default when you create them via the REPL `uimaker`. You can save your tests in any other folder. In order to execute them you need to specify the new path like it was displayed above.

```
namespace \UITesting\Tests;

use RafaelMoran\UITest\UITestCase;

// New test case needs to extend from abstract class UITestCase.
class CarTestCase extends UITestCase
{
	/**
	 * Tests if (new Car)->getType() returns a non-empty string.
	 *
	 * @return void
	 */
	public function test_cartype_is_string_and_not_empty() : void
	{
		$car_type = (new Car)->getType();

		$this->assertNotEmpty($car_type)
			->assertIsString($car_type);
	}

	/**
	 * Tests if values are float type.
	 *
	 * @return void
	 */
	public function test_if_value_is_float() : void
	{
		$this->assertIsFloat(27.25);
		$this->assertIsFloat('abc');
		$this->assertIsFloat(23);
		$this->assertIsFloat(23.5);
		$this->assertIsFloat(1e7);  // Scientific Notation. This is true.
		$this->assertIsFloat(true);
	}

}
```

There is a small REPL that helps you to create new test cases, this REPL is `uimaker`

Usage: How to use REPL uitest
-----------------------------

[](#usage-how-to-use-repl-uitest)

```
$ cd uitesting // Or make an alias that point to `php uitest` globally

```

This command will create a new test case, named `ClassNameX`:

```
$ composer uimaker -n=ClassNameX

```

```
namespace \UITesting\Tests;

use RafaelMoran\UITest\UITestCase;

class ClassNameXTestCase_518135355 extends UITestCase
{
	/**
	 * Tests if 'ClassNameXTestCase_518135355'...
	 *
	 * All tests MUST START WITH "test_".
	 *
	 * @return void
	 */
	public function test_() : void
	{
		/**
		 * Read ./lib/UITestCase.php file regarding assertions.
	 	 *
	 	 * Examples:
	 	 *
	 	 * $this->assertLength( 'abc', 3 ); # true
	 	 * $this->assertArrayHasKey('key3', array('key3'=>null, 'key4'=>1)); # true
		 */
	}

}
```

```
$ composer uimaker -n=FunctionNameX
OR
$ composer uimaker --name=FunctionNameX

```

```
namespace \UITesting\Tests;

use RafaelMoran\UITest\UITestCase;

class FunctionNameXTestCase_518135355 extends UITestCase
{
	/**
	 * Tests if 'FunctionNameXTestCase_518135355'...
	 *
	 * All tests MUST START WITH "test_".
	 *
	 * @return void
	 */
	public function test_() : void
	{
		/**
		 * Read ./lib/UITestCase.php file regarding assertions.
	 	 *
	 	 * Examples:
	 	 *
	 	 * $this->assertLength( 'abc', 3 ); # true
	 	 * $this->assertArrayHasKey('key3', array('key3'=>null, 'key4'=>1)); # true
		 */
	}

}
```

Usage all-in-one
----------------

[](#usage-all-in-one)

```
require_once 'vendor/autoload.php';

$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();

// Examples
include __DIR__ . '/examples/functions.php';
include __DIR__ . '/examples/classes/Car.php';
include __DIR__ . '/examples/classes/AirPlane.php';

// Use case
$tester = new \RafaelMoran\UITest\UITester(['verbose' => true]); // set to false to not display details

// Run all tests
$tester->all();

// Use case
$tester = new UITester(['verbose' => true]); // It displays all assertions in detail

// Or...

$tester = new UITester(['v' => true]); // It displays all assertions in detail

// ...

// Run all tests
$tester->all();

//...

// Only specific tests (string)
$tester->only('CarTest_518135355')
		->outputTestResults();
```

[![Detailed results and final report](Details%20and%20final%20report.png)](Details%20and%20final%20report.png)

```
// ...

// Only specific tests (array)
$tester->only([
		'CarTest_518135355',
		'GetRandomStrTest_1218383454'
	])
	->outputTestResults();
```

[![Final report](Final%20report.png)](Final%20report.png)

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Copyright and License
---------------------

[](#copyright-and-license)

The ralphmoran/uitest tool is copyright © [Rafael Moran](https://github.com/ralphmoran)and licensed for use under the terms of the MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

2

Last Release

1337d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b19bf8872785dec75dc6a98a923ce081de04e12c8e212d925750996b6b204569?d=identicon)[ralphmoran](/maintainers/ralphmoran)

---

Top Contributors

[![ralphmoran](https://avatars.githubusercontent.com/u/5456155?v=4)](https://github.com/ralphmoran "ralphmoran (128 commits)")

---

Tags

integration-testingtestingunitunittesttestingunitintegrationunittesting

### Embed Badge

![Health badge](/badges/rafaelmoran-uitest/health.svg)

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

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[dg/bypass-finals

Removes final keyword from source code on-the-fly and allows mocking of final methods and classes

56426.3M456](/packages/dg-bypass-finals)[nette/tester

Nette Tester: enjoyable unit testing in PHP with code coverage reporter. 🍏🍏🍎🍏

4917.3M1.5k](/packages/nette-tester)[laracasts/integrated

Simple, intuitive integration testing with PHPUnit.

479206.9k2](/packages/laracasts-integrated)[php-vfs/php-vfs

Virtual file system implementation for use with PHP unit testing.

572.7M24](/packages/php-vfs-php-vfs)[contributte/codeception

Integration of Nette framework to Codeception.

27886.9k1](/packages/contributte-codeception)

PHPackages © 2026

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