PHPackages                             codeception/verify - 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. codeception/verify

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

codeception/verify
==================

BDD assertion library for PHPUnit

3.4.0(3mo ago)14914.6M↓38.9%26[1 PRs](https://github.com/Codeception/Verify/pulls)20MITPHPPHP ^7.4 || ^8.0CI passing

Since Jul 25Pushed 3mo ago9 watchersCompare

[ Source](https://github.com/Codeception/Verify)[ Packagist](https://packagist.org/packages/codeception/verify)[ RSS](/packages/codeception-verify/feed)WikiDiscussions master Synced 1w ago

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

Verify
======

[](#verify)

BDD Assertions for [PHPUnit](https://phpunit.de/) or [Codeception](https://codeception.com/)

[![Latest Stable Version](https://camo.githubusercontent.com/650542fb02d286c7df11d81691241f70b137f7391be12551213bb4ac5bb858b5/68747470733a2f2f706f7365722e707567782e6f72672f636f646563657074696f6e2f7665726966792f762f737461626c65)](https://packagist.org/packages/codeception/verify)[![Total Downloads](https://camo.githubusercontent.com/911a2025fd64f3eb2ac50c5fdcab2cfdeff72821b1ac0011e52d249d46e8c107/68747470733a2f2f706f7365722e707567782e6f72672f636f646563657074696f6e2f7665726966792f646f776e6c6f616473)](https://packagist.org/packages/codeception/verify)[![Build Status](https://camo.githubusercontent.com/35eef107ab5fa3bb142540b777995910bbce234b7948b724116cac14acf7bf8a/68747470733a2f2f7472617669732d63692e6f72672f436f646563657074696f6e2f5665726966792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/Codeception/Verify)[![License](https://camo.githubusercontent.com/53d8636abdb78ceb21302ecfd73f668037dc75197f3ca3384f55985ff5cecaa5/68747470733a2f2f706f7365722e707567782e6f72672f636f646563657074696f6e2f737065636966792f6c6963656e7365)](https://packagist.org/packages/codeception/verify)[![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

This is very tiny wrapper for PHPUnit assertions, that are aimed to make tests a bit more readable. With [BDD](https://en.wikipedia.org/wiki/Behavior-driven_development) assertions influenced by [Chai](https://chaijs.com/), [Jasmine](https://jasmine.github.io/), and [RSpec](https://rspec.info/) your assertions would be a bit closer to natural language.

⚠️ This is the Verify 2.0 documentation, to see v1.x docs click [here.](https://github.com/Codeception/Verify/tree/1.x)

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

[](#installation)

*Requires PHP 7.4 or higher*

```
composer require codeception/verify --dev

```

> ⬆️ **Upgrade from 1.x by following [the upgrade guide.](./UPGRADE.md)**

Usage
-----

[](#usage)

Use in any test `verify` function instead of `$this->assert*` methods:

```
use Codeception\Verify\Verify;

$user = User::find(1);

// equals
verify($user->getName())->equals('davert');

verify($user->getNumPosts())
    ->equals(5, 'user have 5 posts')
    ->notEquals(3);

// contains
Verify::Array($user->getRoles())
    ->contains('admin', 'first user is admin')
    ->notContains('banned', 'first user is not banned');

// greater / less
verify($user->getRate())
    ->greaterThan(5)
    ->lessThan(10)
    ->equals(7, 'first user rate is 7');

// true / false / null
verify($user->isAdmin())->true();
verify($user->isBanned())->false();
verify($user->invitedBy)->null();
verify($user->getPosts())->notNull();

// empty
verify($user->getComments())->empty();
verify($user->getRoles())->notEmpty();

// throws
Verify::Callable($callback)
    ->throws()
    ->throws(Exception::class)
    ->throws(Exception::class, 'exception message')
    ->throws(new Exception())
    ->throws(new Exception('message'));

// does not throw
Verify::Callable($callback)
    ->doesNotThrow()
    ->throws(Exception::class)
    ->doesNotThrow(new Exception());

// and many more !
```

> 📄 **See Verifiers full list [here.](./docs/supported_verifiers.md)**

Alternative Syntax
------------------

[](#alternative-syntax)

If you follow TDD/BDD you'd rather use `expect` instead of `verify`:

```
expect($user->getNumPosts())
    ->notToBeNull()
    ->toBeInt()
    ->toEqual(5, 'user have 5 posts');
```

> 📄 **See Expectations full list [here.](./docs/supported_expectations.md)**

Or `verify_that` which is just an alias function:

```
verify_that($user->getRate())->equals(7, 'first user rate is 7');
```

Extending
---------

[](#extending)

In order to add more assertions you can extend the abstract class `Verify`:

```
use Codeception\Verify\Verify;
use PHPUnit\Framework\Assert;

class MyVerify extends Verify {

    //you can type $actual to only receive a specific data type

    public function __construct($actual = null)
    {
        parent::__construct($actual);
    }

    public function success(string $message = '')
    {
        Assert::assertTrue(true, $message);
    }

}
```

And use it!

```
$myVerify = new MyVerify;

$myVerify->success('it works!');

$myVerify::Mixed('this also')->notEquals('works');
```

License
-------

[](#license)

Verify is open-sourced software licensed under the [MIT](./LICENSE) License. © Codeception PHP Testing Framework

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance80

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community51

Growing community involvement

Maturity80

Battle-tested with a long release history

 Bus Factor3

3 contributors hold 50%+ of commits

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 ~139 days

Recently: every ~277 days

Total

34

Last Release

107d ago

Major Versions

0.4.0 → 1.0.02017-11-12

0.5.0 → 1.3.02020-02-15

1.x-dev → 2.0.0-rc12020-08-31

2.3.0 → 3.0.02023-02-09

PHP version history (6 changes)1.0.0PHP &gt;= 7.0

0.5.0PHP 5.6.\*

1.4.0PHP &gt;= 7.1

2.0.0-rc1PHP ^7.3

2.1.1PHP ^7.3 || ^8.0

2.2.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/395992?v=4)[Gintautas Miselis](/maintainers/Naktibalda)[@Naktibalda](https://github.com/Naktibalda)

![](https://avatars.githubusercontent.com/u/97648?v=4)[davert](/maintainers/davert)[@davert](https://github.com/davert)

---

Top Contributors

[![DavertMik](https://avatars.githubusercontent.com/u/220264?v=4)](https://github.com/DavertMik "DavertMik (31 commits)")[![Naktibalda](https://avatars.githubusercontent.com/u/395992?v=4)](https://github.com/Naktibalda "Naktibalda (22 commits)")[![TavoNiievez](https://avatars.githubusercontent.com/u/64917965?v=4)](https://github.com/TavoNiievez "TavoNiievez (16 commits)")[![Ragazzo](https://avatars.githubusercontent.com/u/1748844?v=4)](https://github.com/Ragazzo "Ragazzo (10 commits)")[![cmoralesweb](https://avatars.githubusercontent.com/u/5377322?v=4)](https://github.com/cmoralesweb "cmoralesweb (7 commits)")[![particleflux](https://avatars.githubusercontent.com/u/3686454?v=4)](https://github.com/particleflux "particleflux (6 commits)")[![sergeyklay](https://avatars.githubusercontent.com/u/1256298?v=4)](https://github.com/sergeyklay "sergeyklay (6 commits)")[![Arhell](https://avatars.githubusercontent.com/u/26163841?v=4)](https://github.com/Arhell "Arhell (3 commits)")[![KorDum](https://avatars.githubusercontent.com/u/1331559?v=4)](https://github.com/KorDum "KorDum (2 commits)")[![stevekr](https://avatars.githubusercontent.com/u/7532372?v=4)](https://github.com/stevekr "stevekr (2 commits)")[![blle-dxo](https://avatars.githubusercontent.com/u/151552137?v=4)](https://github.com/blle-dxo "blle-dxo (2 commits)")[![glensc](https://avatars.githubusercontent.com/u/199095?v=4)](https://github.com/glensc "glensc (2 commits)")[![Vetrinus](https://avatars.githubusercontent.com/u/21343113?v=4)](https://github.com/Vetrinus "Vetrinus (1 commits)")[![asppsa](https://avatars.githubusercontent.com/u/453170?v=4)](https://github.com/asppsa "asppsa (1 commits)")[![ddinchev](https://avatars.githubusercontent.com/u/1397692?v=4)](https://github.com/ddinchev "ddinchev (1 commits)")[![developedsoftware](https://avatars.githubusercontent.com/u/19648131?v=4)](https://github.com/developedsoftware "developedsoftware (1 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (1 commits)")[![greg-1-anderson](https://avatars.githubusercontent.com/u/612191?v=4)](https://github.com/greg-1-anderson "greg-1-anderson (1 commits)")[![icanhazstring](https://avatars.githubusercontent.com/u/883543?v=4)](https://github.com/icanhazstring "icanhazstring (1 commits)")[![ricpelo](https://avatars.githubusercontent.com/u/616169?v=4)](https://github.com/ricpelo "ricpelo (1 commits)")

---

Tags

assertionsbddbdd-assertionscodeceptionphpphpunit

### Embed Badge

![Health badge](/badges/codeception-verify/health.svg)

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

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k129.9M905](/packages/brianium-paratest)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k41.3M38.3k](/packages/orchestra-testbench)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.0M321](/packages/drupal-core-dev)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

30300.1k6](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

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