PHPackages                             paasky/laravel-model-test - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. paasky/laravel-model-test

ActiveLibrary[Testing &amp; Quality](/categories/testing)

paasky/laravel-model-test
=========================

Tests Eloquent Model instances and relations

v0.1.6(3y ago)125MITPHPPHP &gt;=7.2

Since Apr 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Paasky/laravel-model-test)[ Packagist](https://packagist.org/packages/paasky/laravel-model-test)[ Docs](https://github.com/paasky)[ RSS](/packages/paasky-laravel-model-test/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (8)Used By (0)

paasky/laravel-model-test
=========================

[](#paaskylaravel-model-test)

Trait to test that all your Laravel Models are instances of correct classes and all relations work

Installation
============

[](#installation)

`composer require paasky/laravel-model-test --dev`

Usage
=====

[](#usage)

In any PHPUnit test

```
use Paasky\TestsModels;

class MyTest extends TestCase
{
    use RefreshDatabase, TestsModels;

    public function testModels()
    {
        $this->assertModels();
    }
}

```

Configuration
=============

[](#configuration)

Configurations are public attributes of the TestsModels-Trait

modelPaths
----------

[](#modelpaths)

Full path(s) to look in for Model classes, includes sub-folders.
Default: `[app_path('Models')]`

- `$this->modelPaths = [app_path('Models'), app_path('SuperCoolModels')];`
- Tip: If your models are directly in `app`, you can skip auto-discovery and pass an array of classes to `assertModels()`:
    `$this->assertModels([User::class, SomethingElse::class, ...]);`

allowedInstances
----------------

[](#allowedinstances)

Classes that found classes can be an instance of. Useful if your project has a custom Model-class.
Default: `[Model::class]`

- `$this->allowedInstances = [ProjectModel::class];`

allowNonModels
--------------

[](#allownonmodels)

Skip or fail classes that are not instances of `Illuminate\Database\Eloquent\Model`
Default: `false` (Fail)

- `$this->allowNonModels = true;`

requiredInstancePerModel
------------------------

[](#requiredinstancepermodel)

Override `allowedInstances` for specific classes by setting the required instance.
Default: `['App\User' => Authenticatable::class, 'App\Models\User' => Authenticatable::class]`

- `$this->requiredInstancePerModel[SimpleUser::class] = Model::class;`

ignoreMethodsPerNamespace
-------------------------

[](#ignoremethodspernamespace)

Ignore these methods from validation, useful when packages don't typehint the return type and are failing
Use `'*'` to ignore all methods in the namespace
Default: `['Illuminate\\' => ['*']`

- `$this->ignoreMethodsPerNamespace['SomeDude\\Package\\'] = ['dumbMethod'];`

enableBackRelationValidation
----------------------------

[](#enablebackrelationvalidation)

Should back relations (eg User has Post, so Post must have User) be validated
Default: `true`

- `$this->enableBackRelationValidation = false;`

enableBackRelationTypeValidation
--------------------------------

[](#enablebackrelationtypevalidation)

Should back relation return types (eg User HasMany Posts, so Post must BelongTo User) be validated
Default: `true`

- `$this->enableBackRelationTypeValidation = false;`

skipBackRelationMethodsValidationPerModel
-----------------------------------------

[](#skipbackrelationmethodsvalidationpermodel)

Methods to skip for back relation validation
Use `'*'` to ignore all methods of the class
Default: `['App\User' => ['tokens'], 'App\Models\User' => ['tokens']]`

- `$this->skipBackRelationMethodsValidationPerModel[PivotModel::class] = ['*'];`

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

7

Last Release

1102d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21715bf2b57e510a200e512e4aa2ceb53cb0f605b31f358f6d6b1cd857b36d7b?d=identicon)[Paasky](/maintainers/Paasky)

---

Top Contributors

[![Paasky](https://avatars.githubusercontent.com/u/13996916?v=4)](https://github.com/Paasky "Paasky (17 commits)")

---

Tags

testlaravelmodeleloquent

### Embed Badge

![Health badge](/badges/paasky-laravel-model-test/health.svg)

```
[![Health](https://phpackages.com/badges/paasky-laravel-model-test/health.svg)](https://phpackages.com/packages/paasky-laravel-model-test)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[infyomlabs/laravel-generator

InfyOm Laravel Generator

3.8k2.3M13](/packages/infyomlabs-laravel-generator)[hughsaffar/laravel-test-trap

Laravel Test Trap

18406.8k](/packages/hughsaffar-laravel-test-trap)[erikgall/eloquent-phpunit

Test Eloquent models, database schemas &amp; tables, relationships/foreign keys using PHPUnit.

2016.5k](/packages/erikgall-eloquent-phpunit)[sofa/eloquent-testsuite

Helpers for fast and reliable UNIT tests for your Eloquent Models with PHPUnit

10104.7k](/packages/sofa-eloquent-testsuite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
