PHPackages                             fadllabanie/laravel\_unittest\_generator - 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. fadllabanie/laravel\_unittest\_generator

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

fadllabanie/laravel\_unittest\_generator
========================================

v2.5.2(2y ago)710MITPHPPHP &gt;=7.3

Since Oct 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Fadllabanie/laravel-generator)[ Packagist](https://packagist.org/packages/fadllabanie/laravel_unittest_generator)[ RSS](/packages/fadllabanie-laravel-unittest-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (7)Used By (0)

Laravel Unit Test Generator
===========================

[](#laravel-unit-test-generator)

Supercharge your Laravel application's testing workflow with the `laravel-generator` package. This dynamic toolkit is your steadfast ally in creating robust unit tests with a touch of magic!

🚀 Installation
--------------

[](#-installation)

Time to bring the `laravel-generator` into your project. Cast these spells with Composer:

```
composer require fadllabanie/laravel-generator
```

Invoke the artisan to publish your configs:

```
php artisan vendor:publish
```

Finally, migrate to shape your database's destiny:

```
php artisan migrate
```

🔧 Configuration
---------------

[](#-configuration)

For the enchantment to work, your models must be imbued with these arcane properties:

```
public function getFillable()
{
    return [
        'title',
        'description',
    ];
}

public function getFillableType()
{
    return [
        'title' => 'string',
        'description' => 'text',
    ];
}

public function getRelationData()
    {
        return [
            'relationName1' => RelatedModel1::class,
            'relationName2' => RelatedModel2::class,
            // Add other relationships as needed
        ];
    }
```

Supported data types include: `string`, `text`, `integer`, `float`, `date`, `image`, `datetime`, `boolean`, `password`, `email`, `token`, `belongsTo`

📖 Usage
-------

[](#-usage)

With the package now part of your repository, conjure unit tests for your models with a simple artisan command:

```
php artisan generator:run {Model} {ModelPath} {options}
```

```
php artisan generator:run Post App/Models -f -r -c
```

📖 NOTE:
-------

[](#-note)

- if use `belongsTo` you should create relation model first and add getRelationData i model

🎛️ Options
----------

[](#️-options)

Fine-tune your unit test generation with these options:

- `-f` or `--factory`: Summon a factory alongside your test for authentic data alchemy.
- `-c` or `--controller`: Invoke a controller test for double the sorcery.
- `-r` or `--request`: Enforce request validation tests for an impenetrable defense.

✨ Features
----------

[](#-features)

- **Generate Factories**: Automatically create factories based on your model's `$fillable` and `$fillableType`.
- **CRUD Unit Tests**: Conjure tests for Create, Read, Update, Delete, and relationships in one incantation.
- **Action Pattern Controller**: Organize your controller logic with discrete Action classes for clarity and reusability.

🧪 Generate Factories
--------------------

[](#-generate-factories)

The command transmutes your model properties into a factory class, paving the way for effortlessly creating test data:

```
php artisan generator:run {Model} {ModelPath} -f
```

🔒 Generate Request Validation Tests
-----------------------------------

[](#-generate-request-validation-tests)

Strengthen your application's defenses by automating Request Validation tests:

```
php artisan generator:run {Model} {ModelPath} -r
```

🛠️ Generate Controller with Action Pattern
------------------------------------------

[](#️-generate-controller-with-action-pattern)

Embrace clean architecture by splitting controller logic into dedicated Action classes:

```
php artisan generator:run {Model} {ModelPath} -c
```

💡 The Magic Behind the Trait
----------------------------

[](#-the-magic-behind-the-trait)

Our Error Logging Trait is your silent guardian, logging every misstep in the shadows so your app never falters.

### Benefits

[](#benefits)

- **Automated Error Tracking**: Capture errors without lifting a wand.
- **Easy Error Retrieval**: Consult the database as your crystal ball for error insights.
- **Streamlined Debugging**: Navigate the maze of bugs with an enchanted map.

### How to Generate

[](#how-to-generate)

To arm your controllers with our trait, simply integrate it with:

```
php artisan generator:run {Model} {ModelPath} -f -r -c
```

📜 Known Issues
--------------

[](#-known-issues)

Ensure your models are correctly named and that your `composer.json` pathways are prophesied correctly. The `$fillable` and `$fillableType` must be declared to conjure tests properly.

📚 Contributing
--------------

[](#-contributing)

Join our coven of contributors! Whether it's fixes, enhancements, or new features, your pull requests shall be greeted with a feast.

---

This README not only guides users through the mystical arts of unit test generation but also conveys the magical essence of the package. It aims to engage developers by blending technical instructions with thematic charm.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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 ~12 days

Total

6

Last Release

864d ago

Major Versions

v1.8.1 → v2.0.02023-11-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/c1c7750e3903ccaec3041f1b3374de4af1c927271e5f9155cfddfd4de48108e6?d=identicon)[fadllabanie](/maintainers/fadllabanie)

---

Top Contributors

[![fdl-labanie](https://avatars.githubusercontent.com/u/135807531?v=4)](https://github.com/fdl-labanie "fdl-labanie (20 commits)")

### Embed Badge

![Health badge](/badges/fadllabanie-laravel-unittest-generator/health.svg)

```
[![Health](https://phpackages.com/badges/fadllabanie-laravel-unittest-generator/health.svg)](https://phpackages.com/packages/fadllabanie-laravel-unittest-generator)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[illuminate/testing

The Illuminate Testing package.

3315.6M113](/packages/illuminate-testing)[christophrumpel/missing-livewire-assertions

This package adds missing livewire test assertions.

149336.0k9](/packages/christophrumpel-missing-livewire-assertions)[calebdw/larastan-livewire

A Larastan / PHPStan extension for Livewire.

43482.4k3](/packages/calebdw-larastan-livewire)[encodia/laravel-health-env-vars

Custom check for Spatie's Laravel Health - Ensure every .env variable you need has been set

20143.5k](/packages/encodia-laravel-health-env-vars)

PHPackages © 2026

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