Skip to content

Commit 2394e04

Browse files
committed
ICM: RuntimeException instead of simple code setting.
1 parent c277a81 commit 2394e04

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/WithoutOverlapping.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminated\Console;
44

5+
use RuntimeException;
56
use Symfony\Component\Console\Input\InputInterface;
67
use Symfony\Component\Console\Output\OutputInterface;
78

@@ -18,9 +19,7 @@ protected function initializeMutex()
1819
{
1920
$mutex = new Mutex($this);
2021
if (!$mutex->acquireLock($this->getMutexTimeout())) {
21-
$this->setCode(function () {
22-
$this->info('Command is running now!');
23-
});
22+
throw new RuntimeException('Command is running now!');
2423
}
2524

2625
register_shutdown_function([$this, 'releaseMutexLock'], $mutex);

tests/ConsoleMutex/WithoutOverlappingTraitTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Mockery;
77
use MysqlStrategyCommand;
88
use NullTimeoutCommand;
9+
use RuntimeException;
910
use TimeoutCommand;
1011

1112
class WithoutOverlappingTraitTest extends TestCase
@@ -101,11 +102,11 @@ public function it_blocks_if_trying_to_run_another_instance_of_the_command()
101102
{
102103
$mutex = Mockery::mock('overload:Illuminated\Console\Mutex');
103104
$mutex->shouldReceive('acquireLock')->with(0)->once()->andReturn(false);
104-
$mutex->shouldReceive('releaseLock')->withNoArgs();
105105

106-
$this->artisan('icm:generic');
106+
$this->expectException(RuntimeException::class);
107+
$this->expectExceptionMessage('Command is running now!');
107108

108-
$this->seeArtisanOutput('Command is running now!');
109+
$this->artisan('icm:generic');
109110
}
110111

111112
/**

0 commit comments

Comments
 (0)