我必须在laravel中使用phpunit运行测试时按Enter键。

5 浏览
0 Comments

我必须在laravel中使用phpunit运行测试时按Enter键。

我必须在使用 Laravel 5.7 中的 PHPUnit 运行测试时按下 Enter。

在每个测试中,我都会收到以下消息:

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;

之后,窗口在运行测试套件时挂起,我需要按下 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);
    }

admin 更改状态以发布 2023年5月21日
0
0 Comments

所以现在我终于找到了解决方案。

在我从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'),

现在一切正常。

问候 Daniel

0
0 Comments

这个对我解决了问题
https://stackoverflow.com/a/48303288/2171254

在这样做之后,我不再需要这一行代码:public $mockConsoleOutput = false;

问候

0