Laravel 8, Model factory class not found

前端 未结 6 1477
孤街浪徒
孤街浪徒 2021-01-17 16:47

so when using the new model factories class introduced in laravel 8.x, ive this weird issue saying that laravel cannot find the factory that corresponds to the model. i get

6条回答
  •  时光取名叫无心
    2021-01-17 17:16

    I was having this same issue, but for a different reason. If you're using factories in the setUp function of a test, make sure:

    1. You're extending Tests\TestCase (instead of PHPUnit\Framework\TestCase)
    2. The first line of your setUp function should be parent::setUp(); (I was missing this)

提交回复
热议问题