Call to a member function connection() on null Laravel 5.4

前端 未结 2 544
轮回少年
轮回少年 2021-01-15 01:17

Try write a unit test and i need do sql query

class UpdateThrowsTest extends TestCase
{

protected $bgame;
protected $game_id = 95;

public function setUp()         


        
相关标签:
2条回答
  • 2021-01-15 01:35

    If anyone bounce to this error during test with Laravel 6 project.

    Try to check if the extends TestCase is using the right TestCase. It could be due to Laravel 6 make:test generated test using the wrong TestCase.

    Change

    use PHPUnit\Framework\TestCase;
    

    To

    use Tests\TestCase;
    

    The problem should solve.

    0 讨论(0)
  • 2021-01-15 01:43

    I had this error on laravel 7 (nothing worked even php artisan serve) and fixed it with

    composer dumpautoload 
    

    Before that update my vendor with composer update and then everything worked fine.

    0 讨论(0)
提交回复
热议问题