codeception/verify
Tiny BDD-style assertion wrapper for PHPUnit/Codeception. Use verify() and Verify::Array/Callable for readable, chainable expectations like equals, contains, greater/less, true/false/null, empty/notEmpty, throws/doesNotThrow—closer to natural language.
The codeception/verify package provides fluent, BDD-style assertion methods for PHP testing, compatible with both PHPUnit and Codeception. Start by installing via Composer:
composer require --dev codeception/verify
Once installed, you can immediately use its assertions in your tests without extra configuration. For example, in a Codeception acceptance test:
$I->see('Welcome', 'h1'); // standard Codeception method
$I->assertEquals('Welcome', $I->grabTextFrom('h1')); // PHPUnit-style
// vs. verify:
verify($I->grabTextFrom('h1'))->equals('Welcome');
verify($I->grabTextFrom('h1'))->contains('Wel');
verify($user)->isNotNull()->hasProperty('email')->property('email')->equals('user@example.com');
This package shines when chaining assertions for readability—ideal for behavior-driven test suites.
verify($result)->array()->hasKey('status')->equals('ok').verify($object)->property('name')->equals('John') or nested verify($object)->method('getAge')->equals(30).PHPUnit assertions in _support/Helper/Functional.php or acceptance suites with verify() to improve test clarity.verify($value, 'User email should match')->equals('test@example.com')._bootstrap.php or AcceptanceTester helpers to validate fixtures or API responses before test steps.expect() (from codeception/verify’s sibling codeception/lib-innerbrowser) for assertion pipelines in functional tests.verify() as a global helper, avoid naming collisions—declare use function Codeception\verify; at the top of your test files, or import the function via use function in PHP 7+.verify() throws \Codeception\Verify\VerifyException on failure, but not standard PHPUnit\Framework\AssertionFailedError—debug failures with --debug or --steps flags in Codeception.true() and false() end the chain); check method signatures—some require .verify() context./** @var \Codeception\Verify\Verify $verify */ before chaining complex chains to avoid IDE warnings.AppVerify) that wrap verify() with domain-specific logic (e.g., verifyUser($user)->isEmailVerified()).phpunit/phpunit’s built-in assertions for standalone PHPUnit projects unless BDD fluency is critical.How can I help you explore Laravel packages today?