我必须在Laravel 5.7中使用phpunit按Enter键运行测试。
每次测试我得到以下消息:
1)Tests \ Feature \ DepartmentsTest :: a_admin_can_create_a_department Mockery \ Exception \ BadMethodCallException:收到Mockery_1_Illuminate_Console_OutputStyle :: askQuestion(),但没有指定期望
通过将以下设置为false,错误消失:
public $mockConsoleOutput = false;
之后窗口会在运行测试套件时挂起,我需要按Enter键来运行测试。
我该如何解决这个问题?
我使用的是Windows 10 + PHPUnit 7.5.1和Laravel 5.7.19
提前致谢!
/** @test */
public function a_admin_can_create_a_department()
{
// $this->withoutExceptionHandling();
$attributes = [
'description' => 'Service',
'accessible_by_depart' => true
];
$this->post('/tools/api/storeDepartment', $attributes);
$this->assertDatabaseHas('departments', $attributes);
}
所以现在我终于找到了解决方案。
我从Laravel 5.1迁移到Laravel 5.2(很久以前)我忘了在config / app.php文件中添加以下行:
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
现在一切正常。
问候丹尼尔
这解决了我https://stackoverflow.com/a/48303288/2171254的问题
在这之后,我不需要行public $mockConsoleOutput = false;
问候