dmitry-ivanov / laravel-console-mutex

Mutex for Laravel Console Commands.
MIT License
139 stars 31 forks source link

Issue with PHPUnit testing and mutex not released #30

Closed Okipa closed 2 years ago

Okipa commented 2 years ago

Versions:

Description:

Everything is working fine when I use the package in real conditions.

However, I can't make tests on commands that are implementing the WithoutOverlapping trait: the first test is OK but all other tests are throwing the Illuminated\Console\MutexRuntimeException: Command is running now! error.

I verified by adding a dd('test') in the releaseMutexLock from the NinjaMutex\Lock\FlockLock (default file strategy is set with no timeout) and 4 tests are executed before the mutex is released.

Is there a way to force the mutex to be released after each test ?

Steps to reproduce:

Implement a command and write several tests in a same test class, the mutex will not be released between each test.

Expected:

The mutex should be released right after the command has finished.

Actual:

The mutex is not released right after the command has finished.

dmitry-ivanov commented 2 years ago

Hi @Okipa,

Could you please try this as a solution?

I hope it helps!