我有以下测试用例
public function it_can_delete_all_log_files()
{
.....
.....
static::assertSame(0, $this->artisan('log-viewer:clear'));
.....
}现在的问题是命令要求确认(单元测试停止,我必须输入yes或no),我找不到一种从phpunit以编程方式提供确认的方法。我该怎么做呢?
发布于 2018-04-25 21:19:09
我的建议是尝试以编程的方式清除使用..
命令以编程方式运行PHP ARTISAN
清除缓存外观值:
Route::get('/clear-cache', function() {
$exitCode = Artisan::call('cache:clear');
return '<h1>Cache facade value cleared</h1>';
});重新优化的类加载器:
Route::get('/optimize', function() {
$exitCode = Artisan::call('optimize');
return '<h1>Reoptimized class loader</h1>';
});路由缓存:
Route::get('/route-cache', function() {
$exitCode = Artisan::call('route:cache');
return '<h1>Routes cached</h1>';
});清除路由缓存:
Route::get('/route-clear', function() {
$exitCode = Artisan::call('route:clear');
return '<h1>Route cache cleared</h1>';
});清除视图缓存:
Route::get('/view-clear', function() {
$exitCode = Artisan::call('view:clear');
return '<h1>View cache cleared</h1>';
});清除配置缓存:
Route::get('/config-cache', function() {
$exitCode = Artisan::call('config:cache');
return '<h1>Clear Config cleared</h1>';
});https://stackoverflow.com/questions/50022818
复制相似问题