0

i must press enter on running tests using phpunit in Laravel 5.7.

On every test i get following Message:

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

by setting following to false, the error disappear:

public $mockConsoleOutput = false;

After that the window hangs on running the test suite and i need to press enter to run the tests.

How can i fix that?

I´am using Windows 10 + PHPUnit 7.5.1 and Laravel 5.7.19

Thanks in advance!

/** @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);
    }
3
  • Can you post the Tests\Feature\DepartmentsTest::a_admin_can_create_a_department code? Commented Dec 20, 2018 at 23:30
  • @Peter edited the post, see above Commented Dec 21, 2018 at 12:13
  • Can you show your $this->post() method too? Basically we need to see where you are setting up your mock. Commented Dec 21, 2018 at 21:32

2 Answers 2

1

This fixed the problem for me https://stackoverflow.com/a/48303288/2171254

After doing that, I didn't need the line public $mockConsoleOutput = false;

Greetings

Sign up to request clarification or add additional context in comments.

Comments

0

So now I finally found the solution.

On my migration from Laravel 5.1 to Laravel 5.2 (a long time ago) i forgot to add the following lines to the config/app.php File:

    /*
    |--------------------------------------------------------------------------
    | 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'),

Now everything works fine.

Greetings Daniel

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.