dmitry-ivanov/laravel-console-mutex

Issue with PHPUnit testing and mutex not released

Closed this issue · 1 comments

Okipa commented

Versions:

  • Package Version: 8.1.0
  • PHP Version: 8.0

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.

Hi @Okipa,

Could you please try this as a solution?

I hope it helps!