我必须在 运行 中使用 phpunit 在 laravel 中按回车键进行测试
i must press enter on running tests using phpunit in laravel
我必须在 运行 在 Laravel 5.7 中使用 phpunit 进行测试时按回车键。
每次测试我都会收到以下消息:
1) Tests\Feature\DepartmentsTest::a_admin_can_create_a_department
Mockery\Exception\BadMethodCallException: Received
Mockery_1_Illuminate_Console_OutputStyle::askQuestion(), but no
expectations were specified
将以下设置为false,错误消失:
public $mockConsoleOutput = false;
在那之后 window 在测试套件上 运行 挂起,我需要按回车键 运行 测试。
我该如何解决?
我正在使用 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'),
现在一切正常。
问候丹尼尔
这解决了我的问题
这样做之后,我就不需要行 public $mockConsoleOutput = false;
问候
我必须在 运行 在 Laravel 5.7 中使用 phpunit 进行测试时按回车键。
每次测试我都会收到以下消息:
1) Tests\Feature\DepartmentsTest::a_admin_can_create_a_department Mockery\Exception\BadMethodCallException: Received Mockery_1_Illuminate_Console_OutputStyle::askQuestion(), but no expectations were specified
将以下设置为false,错误消失:
public $mockConsoleOutput = false;
在那之后 window 在测试套件上 运行 挂起,我需要按回车键 运行 测试。
我该如何解决?
我正在使用 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'),
现在一切正常。
问候丹尼尔
这解决了我的问题
这样做之后,我就不需要行 public $mockConsoleOutput = false;
问候