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
Eloquent Model Tester

Eloquent Model Tester Laravel Package

codenco-dev/eloquent-model-tester

Laravel dev-only helper to test Eloquent models: verify table structure/columns, fillable vs guarded attributes, and model relationships. Works with PHPUnit and model factories, integrates easily in your model test classes.

View on GitHub
Deep Wiki
Context7

Test easier your Eloquent Models in your Laravel Project

Frequently asked questions about Eloquent Model Tester
How do I install `codenco-dev/eloquent-model-tester` for Laravel?
Run `composer require codenco-dev/eloquent-model-tester --dev` to install it as a development dependency. This avoids runtime overhead and keeps it isolated to your testing environment.
Does this package work with Laravel 10 and newer?
Yes, the package is designed to work with modern Laravel versions (8.x and above). Check the [GitHub repository](https://github.com/codenco-dev/eloquent-model-tester) for the latest compatibility notes.
Can I use this package without model factories?
No, factories are required for meaningful tests, especially for relationships. If you lack factories, generate them using `php artisan make:model ModelName -mf` or manually define them in `database/factories`.
Will this package slow down my CI/CD pipeline?
It may introduce minor overhead due to database introspection, but the impact is usually negligible. For large projects, consider running schema tests separately or in parallel with other test suites.
How do I test model relationships with this package?
Use methods like `assertHasRelation()` to verify relationships exist and are correctly configured. Ensure your factories include related models to avoid false negatives in tests.
Can I integrate this with Pest instead of PHPUnit?
Yes, the package works with both PHPUnit and Pest. Simply extend your Pest test classes with `HasModelTester` and use the provided assertions like `assertTableStructure()`.
What if my test database schema differs from production?
Schema tests may fail if migrations or seeders differ between environments. Use `RefreshDatabase` or `MigrateFreshDatabase` traits to reset the test database before tests, ensuring consistency.
Does this package replace Laravel’s built-in Schema assertions?
No, it complements them. While Laravel’s `assertDatabaseHas()` or `assertDatabaseMissing()` work for row-level checks, this package focuses on model structure, fillable/guarded attributes, and relationships.
How do I handle custom database connections in tests?
The package assumes the default Laravel database connection. For custom connections, manually configure the test environment or extend the package’s traits to support your setup.
What’s the best way to start using this in an existing project?
Begin with 1–2 critical models (e.g., `User`, `Order`) to validate its value. Use `php artisan make:test Models/ModelNameTest` and gradually expand coverage. Document your test conventions to align the team.
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle