Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Čamo's avatar

Čamo wrote a reply+100 XP

4mos ago

Laravel 12 CommandFinished does not run for php artisan test

No I do not see the event if the command is test. What version of Laravel do you have? Any other command works as expected but not php artisan test.

Čamo's avatar

Čamo wrote a reply+100 XP

4mos ago

Laravel 12 CommandFinished does not run for php artisan test

This is not true it is related only to commands tests - when test testing some command

Čamo's avatar

Čamo wrote a reply+100 XP

4mos ago

Laravel 12 CommandFinished does not run for php artisan test

As I found out the CommandFinished is not allowed by default in Laravel 12 in tests https://laravel.com/docs/12.x/console-tests#console-events It has to be allowed by adding trait use WithConsoleEvents. But it does not work although I add the trait to the script.

Čamo's avatar

Čamo wrote a reply+100 XP

4mos ago

Laravel 12 CommandFinished does not run for php artisan test

No success. This implementation behave the same way. As I run any command like cache:clear it works but as I run test it does not log anything.

Čamo's avatar

Čamo wrote a reply+100 XP

4mos ago

Laravel 12 CommandFinished does not run for php artisan test

Did you try also the Listener class? Do you have the same behaviours with test command?

Čamo's avatar

Čamo wrote a reply+100 XP

4mos ago

Laravel 12 CommandFinished does not run for php artisan test

Thank you very much, i will check it as soon as possible.

Čamo's avatar

Čamo wrote a reply+100 XP

5mos ago

Laravel 12 CommandFinished does not run for php artisan test

No Event::fake() is not in any of tests

Čamo's avatar

Čamo started a new conversation+100 XP

5mos ago

Form error causes recaptcha error

Hi I tried to create new discussion here and made some mistakes so the submit returns an errors. I forget to choose channel or title second time... But if any error occures second submit returns error with recaptcha so it is impossible to submit the form. Secondly I do not see any recaptcha here.

Čamo's avatar

Čamo started a new conversation+100 XP

5mos ago

Laravel 12 CommandFinished does not run for php artisan test

I would like to implement some logic after all tests in Laravel 12 application finished. I found this blog from 2024 https://laravel.com/docs/12.x/events#main-content which is based on CommandFinished native event. So I made a CommandFinishedListener. If I run php artisan event:list I see the lister in the list. So it is obviously registered. If I run any command it works BUT as I run php artisan test the listener does not run. All tests pass but the event does not trigger. Thanks for any help.

Čamo's avatar

Čamo liked a comment+100 XP

5mos ago

How to show custom error message in laravel tests

Do not use the assertStatus method, instead use a generic assertion where you can specify the failure message:

foreach ($this->main_pages as $page) {
    $response = $this->get($page);

    \PHPUnit\Framework\Assert::assertTrue(
        $response->getStatusCode() === 200,
        "Unable to reach page: {$page}"
    );
}
Čamo's avatar

Čamo wrote a reply+100 XP

6mos ago

Parallel testing with multiple database connections

I am facing the same problem right now. It seems there is still no solution on framework level. What I found it this blog. did not test it yet but hope it will help https://sarahjting.com/blog/laravel-paratest-multiple-db-connections