Laravel create database when testing

后端 未结 4 1521
清歌不尽
清歌不尽 2021-01-02 05:35

I am trying to run my unit test and create a database during setup. For some reason I am getting the error Unknown database \'coretest\'. If I create the databa

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-02 06:00

    In Laravel 5 it's possible to call migrations internally to the Laravel process which ends up running a good bit quicker than using external commands.

    In TestCase::setUp (or earlier), call the migration command with:

    $kernel = app('Illuminate\Contracts\Console\Kernel');
    $kernel->call('migrate');
    

提交回复
热议问题