简体   繁体   English

使用测试数据库设置Laravel Dusk

[英]Setting up Laravel Dusk with testing database

VERSIONS: Laravel v5.8.21 & Laravel Dusk v5.1.0 版本:Laravel v5.8.21和Laravel Dusk v5.1.0

I'm having real issues with getting Dusk to work with a testing database. 让Dusk与测试数据库一起工作时遇到了实际问题。 I seem to have gone through every piece of advice and still no luck. 我似乎已经完成了每一条建议,但仍然没有运气。 Dusk is not loading my .env.dusk.local file for some reason. 出于某种原因,Dusk没有加载我的.env.dusk.local文件。 Can anyone help? 有人可以帮忙吗?

// test
class ApplicationTest extends DuskTestCase
{
    use DatabaseMigrations;

    /** @test */
    public function it_works()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/test')->assertSee('It works!');
        });
    }
}

// .env.dusk.local
APP_NAME="Laravel"
APP_ENV=local
APP_URL=http://127.0.0.1:8000

DB_CONNECTION=dusk

// database.php
'dusk' => [
    'driver' => 'sqlite',
    'database' => database_path('dusk.sqlite'),
    'prefix' => '',
]

Then I run the PHP web server with php artisan serve --env=dusk.local however Dusk uses the .env file and goes to my development site using the development database. 然后我使用php artisan serve --env=dusk.local运行PHP Web服务器php artisan serve --env=dusk.local但是Dusk使用.env文件并使用开发数据库转到我的开发站点。

What am I doing wrong? 我究竟做错了什么?

I think you might need to update Laravel. 我想你可能需要更新Laravel。 Are you using an older version of the framework? 您使用的是旧版本的框架吗? This used to be a bug pre-5.8.7. 这曾经是5.8.7之前的错误。 See: https://github.com/laravel/framework/issues/27828 请参阅: https//github.com/laravel/framework/issues/27828

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM