- What is erikgall/eloquent-phpunit used for?
- It is a PHPUnit integration package for testing Eloquent models, database schemas and tables, and relationships or foreign keys. It reduces boilerplate around test setup and database assertions. It is useful for Laravel applications and standalone Eloquent test suites.
- How do I install erikgall/eloquent-phpunit in a Laravel project?
- Install it as a Composer dev dependency with composer require --dev erikgall/eloquent-phpunit. Then use its helpers inside your PHPUnit tests. Check the package composer.json for PHP and Laravel version constraints before adding it to an existing project.
- Which Laravel and PHP versions does erikgall/eloquent-phpunit support?
- The supported Laravel and PHP versions are defined by the package Composer constraints, so check composer.json and Packagist before adoption. The v1.0.7 release is a patch-level addition, which suggests backward compatibility within the 1.x line. Verify compatibility against your project's exact Laravel and PHP versions in CI.
- What Eloquent relationships can I assert with erikgall/eloquent-phpunit?
- The package provides helpers for asserting Eloquent relationships, and v1.0.7 adds a hasOne relationship test method. The overview also covers relationships and foreign keys generally, so check the current source or documentation for exact helper coverage. Confirm whether hasMany, belongsTo, belongsToMany, and polymorphic helpers are included before relying on them.
- Do I need to configure erikgall/eloquent-phpunit after installation?
- Configuration appears minimal: add the package as a dev dependency, let Composer autoload it, and use the helpers in your tests. It should not require production code changes or test migrations. Check the README or source for any required base test case, trait, or setup step.
- Can I use erikgall/eloquent-phpunit with Pest tests?
- The package is described as PHPUnit integration, and Pest runs on top of PHPUnit, so the helpers may be usable from Pest tests if they are accessible in that context. The provided context does not explicitly confirm Pest support. Test a small Pest case before standardizing on it.
- Does erikgall/eloquent-phpunit affect production deployments?
- No, it is intended as a require-dev testing tool and does not alter runtime behavior or public APIs used in production. Keep it out of production dependencies and deployments. As with any dev dependency, ensure your production Composer install excludes dev packages.
- How do I test a hasOne relationship with erikgall/eloquent-phpunit?
- Create the parent model and its related hasOne record in your test, then use the package's hasOne assertion helper to verify the relationship. The v1.0.7 release specifically adds this method for common hasOne coverage. Check the package source or docs for the exact method name and expected arguments.
- What are alternatives to erikgall/eloquent-phpunit for Laravel relationship tests?
- Laravel's built-in testing helpers, such as database assertions and model relationship methods, plus plain PHPUnit are the main alternatives. They require more boilerplate but have no extra dependency. Compare the helper coverage and maintenance status of erikgall/eloquent-phpunit against your team's existing test patterns before switching.
- Is erikgall/eloquent-phpunit actively maintained and safe to use?
- Maintenance status should be verified by checking the GitHub repository, issue tracker, release cadence, and Packagist metadata. The v1.0.7 patch is additive and test-only, which keeps technical risk low. Pin the package version and run your test suite in CI to catch compatibility or helper correctness issues. Confirm the license and support expectations before standardizing on it.