Skip to content

Tests does not trigger CommandFinished #58346

@camohub

Description

@camohub

Laravel Version

12.0

PHP Version

8.2.6

Database Driver & Version

No response

Description

I would like to use Illuminate\Console\Events\CommandFinished to handle all tests result as one bunch of data. So I decided to use CommandFinished which seems to fit perfectly my needs. BUT as I found out this event works fine with any other artisan commands but not with test command. I made some simple logs in listener handle method and as I said every artisan command works fine BUT test command does not trigger the event.

Steps To Reproduce

I have CommanfFinishedListener class which listen for CommandFinished event registered. I see the listener is registered properly. I also see the listern and event works fine with any other artisan commands but not with test command. This is my

<?php

namespace App\Listeners;


use App\Services\BaseService;
use Illuminate\Console\Events\CommandFinished;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;


class CommandFinishedListener
{
    /**
     * Create the event listener.
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     */
    public function handle(CommandFinished $event)
    {
        Log::info('111111111111111');  // I see this log for any other command BUT NOT for test command
        Log::info('CommandFinishedListener: ' . $event->command);

        if ( $event->command === 'test' ) {
            Log::info('2222222222222');  // This is never logged anywhere
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions