Php 关闭Redis以在Laravel中进行测试
我想在测试时关闭Redis 现在我被困在这里: 像这样更改Php 关闭Redis以在Laravel中进行测试,php,laravel,configuration,redis,Php,Laravel,Configuration,Redis,我想在测试时关闭Redis 现在我被困在这里: 像这样更改phpunit.xml 在我的控制器中,我有一个字符串redistener::setupConnection('production') 最后一个是RedistListener: class RedisListener { public static function setupConnection() { if (env('APP_ENV') != 'testing') { retu
phpunit.xml
在我的控制器中,我有一个字符串redistener::setupConnection('production')代码>
最后一个是RedistListener:
class RedisListener
{
public static function setupConnection() {
if (env('APP_ENV') != 'testing') {
return config(['database.redis.default.host' => 'false']); //Don't know what I should write here
}
}
}
我可以在配置中更改一些值,但显然没有帮助)
我该怎么办 如果您想在测试时更改redis主机,请使用phpunit.xml中的
如果您想在单独的数据库上运行单元测试,我建议您配置inmemory sqlite
config/database.php
'sqlite' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]
并将phpunit.xml中的数据库连接更改为
然后不要忘记在测试中使用DatabaseMigrations特性