Download the PHP package thomasdominic/eloquent-model-testor without Composer
On this page you can find all versions of the php package thomasdominic/eloquent-model-testor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thomasdominic/eloquent-model-testor
More information about thomasdominic/eloquent-model-testor
Files in thomasdominic/eloquent-model-testor
Package eloquent-model-testor
Short Description Test easier your Eloquent Models in your Laravel Project
License MIT
Homepage https://github.com/thomasdominic/eloquent-model-testor
Informations about the package eloquent-model-testor
Helper for Testing structures, relations of your models in Laravel
This package allows you to test your models about table structures, relations and more
Installation
You can install the package via composer:
Usage
To use this package, you have to generate factories for your models. (See Factories Documentation)
You can generate one test file by model or for several. For your model MyModel
you can use this command for example:
Test of structure and of fillable
With this structure
users
id - integer
name - string
other_field - string
you can test if you have all the fields you need and if they are fillable.
HasMany et BelongsTo
You can test relations of your models. For example, with this structure
categories
id - integer
name - string
customers
id - integer
name - string
category_id - integer
type_id - integer
you can use assertHasHasManyRelations
and assertHasBelongsToRelations
methods like this
If you don't use Laravel naming convention, you may also override the relation and local keys (for belongsTo relation) by passing
additional arguments to the assertHasHasManyRelations
and assertHasBelongsToRelations
methods
If you have several relations, you can chain methods like this:
Many to Many relations
You can test your ManyToMany relations with the ManyToManyRelationsTestable
trait.
users
id - integer
name - string
roles
id - integer
name - string
role_user
user_id - integer
role_id - integer
You can override the relation argument too :
Morph Relations
If you have a Morph Relation,
posts
id - integer
title - string
body - text
videos
id - integer
title - string
url - string
comments
id - integer
body - text
commentable_id - integer
commentable_type - string
you can use assertHasBelongsToMorphRelations
and assertHasHasManyMorphRelations
methods like this
Pivot and table without Model
You can test if a table contains columns with the tableTestable
method
Testing
Changelog
Please see CHANGELOG for more information about what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Dominic THOMAS
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.