ฉันต้องกด Enter เมื่อรันการทดสอบโดยใช้ phpunit ใน laravel

ฉันต้องกด Enter เมื่อรันการทดสอบโดยใช้ phpunit ใน Laravel 5.7

ในการทดสอบทุกครั้งฉันได้รับข้อความต่อไปนี้:

1) Tests\Feature\DepartmentsTest::a_admin_can_create_a_department Mockery\Exception\BadMethodCallException: ได้รับ Mockery

public $mockConsoleOutput = false;
Illuminate_Console_OutputStyle::askQuestion() แต่ไม่มีการระบุความคาดหวัง

โดยการตั้งค่าต่อไปนี้เป็นเท็จ ข้อผิดพลาดจะหายไป:

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);
    }

person Daniel Julius    schedule 20.12.2018    source แหล่งที่มา
comment
คุณสามารถโพสต์รหัส Tests\Feature\DepartmentsTest::a_admin_can_create_a_department ได้หรือไม่   -  person Peter    schedule 21.12.2018
comment
@Peter แก้ไขโพสต์ ดูด้านบน   -  person Daniel Julius    schedule 21.12.2018
comment
คุณสามารถแสดงวิธี $this->post() ของคุณด้วยได้ไหม โดยพื้นฐานแล้วเราจำเป็นต้องดูว่าคุณกำลังตั้งค่าการเยาะเย้ยของคุณอยู่ที่ไหน   -  person Peter    schedule 22.12.2018


คำตอบ (2)


ในที่สุดฉันก็พบวิธีแก้ปัญหาแล้ว

ในการโยกย้ายจาก 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'),

ตอนนี้ทุกอย่างทำงานได้ดี

สวัสดีแดเนียล

person Daniel Julius    schedule 27.12.2018

วิธีนี้แก้ไขปัญหาสำหรับฉัน https://stackoverflow.com/a/48303288/2171254

หลังจากนั้นฉันก็ไม่ต้องการบรรทัด public $mockConsoleOutput = false;

ทักทาย

person Gjaa    schedule 05.03.2019