You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Got error Class 'Database\Factories\Entities\Units\UnitFactory' not found when running unit tests after generating CRUD with a model in a different directory (other than app/Models).
Package Version
laravel/framework: v8.37.0
luthfi/simple-crud-generator: 2.3.0
How to Reproduce
$ laravel new simple_crud_test
$ cd simple_crud_test
Update phpunit.xml using sqlite in memory database
Since Laravel 8.x, they are using class-based model factories, they need to automatically resolve the model factory class name based on the model class name.
If the file Factory.php#L718-L720 they are checking if the class namespace is App\Models, the model factory class should be in database/factories/ModelNameFactory.
But when the Laravel model is stored outside the "app/Models", they will resolve the model factory class name based on the model's full namespace.
In my case, if my model path is app/Entities/Units/Unit.php, then they will look for model factory class on database/factories/Entities/Units/UnitFactory.php
Description
Got error
Class 'Database\Factories\Entities\Units\UnitFactory' not found
when running unit tests after generating CRUD with a model in a different directory (other thanapp/Models
).Package Version
How to Reproduce
$ laravel new simple_crud_test
$ cd simple_crud_test
phpunit.xml
using sqlite in memory database$ composer require laravel/ui
$ composer require luthfi/simple-crud-generator --dev
$ php artisan ui bootstrap --auth
$ php artisan make:crud Phone
(Phone
model on theapp/Models
directory)$ vendor/bin/phpunit
(all tests are passed)$ php artisan make:crud Entities/Units/Unit
(Unit
model on theapp/Entities/Units/Unit
directory)$ vendor/bin/phpunit --stop-on-failure
Error: Class 'Database\Factories\Entities\Units\UnitFactory' not found
Screenshot
The text was updated successfully, but these errors were encountered: