Skip to content

Commit 0ba3224

Browse files
committed
ICM: Tests added.
1 parent 0062979 commit 0ba3224

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

tests/MutexTest.php

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
<?php
22

33
use Illuminated\Console\Mutex;
4+
use NinjaMutex\Lock\FlockLock;
45

56
class MutexTest extends TestCase
67
{
8+
private $command;
9+
10+
protected function setUp()
11+
{
12+
parent::setUp();
13+
14+
$this->command = Mockery::mock(GenericCommand::class)->makePartial();
15+
$this->command->shouldReceive('argument')->withNoArgs()->once()->andReturn(['foo' => 'bar']);
16+
}
17+
718
/** @test */
819
public function it_has_one_required_constructor_argument_which_is_command()
920
{
10-
$command = Mockery::mock(GenericCommand::class)->makePartial();
11-
$command->shouldReceive('argument')->withNoArgs()->once()->andReturn(['foo' => 'bar']);
12-
13-
$mutex = new Mutex($command);
21+
$mutex = new Mutex($this->command);
1422
$this->assertInstanceOf(Mutex::class, $mutex);
1523
}
1624

1725
/** @test */
1826
public function it_determines_mutex_strategy_once_while_creation()
1927
{
20-
$command = Mockery::mock(GenericCommand::class)->makePartial();
21-
$command->shouldReceive('argument')->withNoArgs()->once()->andReturn(['foo' => 'bar']);
22-
23-
$mutex = new Mutex($command);
28+
$mutex = new Mutex($this->command);
2429
$this->assertSame($mutex->getStrategy(), $mutex->getStrategy());
2530
}
31+
32+
/** @test */
33+
public function it_has_default_strategy_which_is_file()
34+
{
35+
$this->command->shouldReceive('getMutexStrategy')->withNoArgs()->once()->andReturn('foobar');
36+
37+
$mutex = new Mutex($this->command);
38+
$this->assertEquals(new FlockLock(storage_path('app')), $mutex->getStrategy());
39+
}
2640
}

0 commit comments

Comments
 (0)