PHPackages                             way/phpunit-wrappers - 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. way/phpunit-wrappers

AbandonedLibrary

way/phpunit-wrappers
====================

Should and Assert wrappers for PHPUnit

4534.7k210PHP

Since Mar 21Pushed 13y ago3 watchersCompare

[ Source](https://github.com/JeffreyWay/PHPUnit-Wrappers)[ Packagist](https://packagist.org/packages/way/phpunit-wrappers)[ RSS](/packages/way-phpunit-wrappers/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (10)

Assert and Should
=================

[](#assert-and-should)

> [Prefer a video introduction](https://dl.dropbox.com/u/774859/GitHub-Repos/PHPUnit-Wrappers.mp4)?

This project provides two wrappers (you can add more) around PHPUnit's assertion library. For example, rather than typing:

```
$this->assertEquals(4, 2 + 2);
```

You can instead do:

```
Assert::equals(4, 2 + 2);

# or
Should::equal(4, 2 + 2);
```

To allow for more readability, when using Should, you may prepend `be` or `have`, like so:

```
Should::beTrue(true);
Should::haveCount(2, ['a', 'b']);
```

Aliases
-------

[](#aliases)

Additionally, you can register your own aliases.

```
Should::getInstance()->registerAliases([
	'beCakesAndPies' => 'assertTrue'
]);

# or

Assert::getInstance()->registerAliases([
	'eq' => 'assertEquals'
]);
```

Now, you can use `Should::beCakesAndPies` and `Assert::eq` in your tests, and they will map to `assertTrue` and `assertEquals`, respectively.

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

[](#installation)

Install these helpers through Composer. To your `composer.json` file, add:

```
{
	"require-dev": {
		"way/phpunit-wrappers": "dev-master"
	}
}
```

Next, as always, run a `composer install` or `composer update` for development.

```
composer install --dev
```

That command will pull in those clases under the `Way\Tests` namespace.

Next, within your test file, use your desired assertion wrapper (or both).

```
