Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Verify Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

  • Fluent Method Chaining: Write self-documenting assertions: verify($result)->array()->hasKey('status')->equals('ok').
  • Object Verification: Deep inspection of objects via verify($object)->property('name')->equals('John') or nested verify($object)->method('getAge')->equals(30).
  • Integration with Codeception: Replace verbose PHPUnit assertions in _support/Helper/Functional.php or acceptance suites with verify() to improve test clarity.
  • Custom Descriptions: Add context via verify($value, 'User email should match')->equals('test@example.com').
  • Test Data Validation: Use in _bootstrap.php or AcceptanceTester helpers to validate fixtures or API responses before test steps.
  • Type-Safe Flow: Mix with expect() (from codeception/verify’s sibling codeception/lib-innerbrowser) for assertion pipelines in functional tests.

Gotchas and Tips

  • Namespace Conflicts: If using 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+.
  • Exception Handling: verify() throws \Codeception\Verify\VerifyException on failure, but not standard PHPUnit\Framework\AssertionFailedError—debug failures with --debug or --steps flags in Codeception.
  • Chaining Limitations: Not all methods support chaining (e.g., true() and false() end the chain); check method signatures—some require .verify() context.
  • PHPStan/IDE Support: Enable method hints by importing types: /** @var \Codeception\Verify\Verify $verify */ before chaining complex chains to avoid IDE warnings.
  • Extensibility: Extend assertions by creating your own helper classes (e.g., AppVerify) that wrap verify() with domain-specific logic (e.g., verifyUser($user)->isEmailVerified()).
  • Versioning Warning: The listed "Last release: 2026-02-24" suggests a future-dated release—verify stability and compatibility with your test suite (e.g., PHP 8.1+ required in v3+).
  • Fallback for PHPUnit-Only Tests: If not using Codeception, still works—but prefer phpunit/phpunit’s built-in assertions for standalone PHPUnit projects unless BDD fluency is critical.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation