Skip to content

Commit 1a001bb

Browse files
committed
Mockery ^1.0 features used.
1 parent 074d3d9 commit 1a001bb

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

tests/ConsoleMutex/WithoutOverlappingTraitTest.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Illuminated\Console\ConsoleMutex\Tests;
44

55
use GenericCommand;
6-
use Mockery;
76
use MysqlStrategyCommand;
87
use NullTimeoutCommand;
98
use RuntimeException;
@@ -71,9 +70,9 @@ public function mutex_timeout_can_be_set_to_null_by_the_public_method()
7170
/** @test */
7271
public function it_generates_mutex_name_based_on_the_command_name_and_arguments()
7372
{
74-
$command = Mockery::mock(GenericCommand::class)->makePartial();
75-
$command->shouldReceive('getName')->withNoArgs()->once()->andReturn('icm:generic');
76-
$command->shouldReceive('argument')->withNoArgs()->once()->andReturn(['foo' => 'bar', 'baz' => 'faz']);
73+
$command = mock(GenericCommand::class)->makePartial();
74+
$command->expects()->getName()->andReturn('icm:generic');
75+
$command->expects()->argument()->andReturn(['foo' => 'bar', 'baz' => 'faz']);
7776

7877
$md5 = md5(json_encode(['foo' => 'bar', 'baz' => 'faz']));
7978
$this->assertEquals("icmutex-icm:generic-{$md5}", $command->getMutexName());
@@ -86,9 +85,9 @@ public function it_generates_mutex_name_based_on_the_command_name_and_arguments(
8685
*/
8786
public function it_allows_to_run_command_if_there_is_no_other_running_instances()
8887
{
89-
$mutex = Mockery::mock('overload:Illuminated\Console\Mutex');
90-
$mutex->shouldReceive('acquireLock')->with(0)->once()->andReturn(true);
91-
$mutex->shouldReceive('releaseLock')->withNoArgs();
88+
$mutex = mock('overload:Illuminated\Console\Mutex');
89+
$mutex->expects()->acquireLock(0)->andReturn(true);
90+
$mutex->allows()->releaseLock();
9291

9392
$this->artisan('icm:generic');
9493
}
@@ -100,11 +99,10 @@ public function it_allows_to_run_command_if_there_is_no_other_running_instances(
10099
*/
101100
public function it_blocks_if_trying_to_run_another_instance_of_the_command()
102101
{
103-
$mutex = Mockery::mock('overload:Illuminated\Console\Mutex');
104-
$mutex->shouldReceive('acquireLock')->with(0)->once()->andReturn(false);
102+
$mutex = mock('overload:Illuminated\Console\Mutex');
103+
$mutex->expects()->acquireLock(0)->andReturn(false);
105104

106-
$this->expectException(RuntimeException::class);
107-
$this->expectExceptionMessage('Command is running now!');
105+
$this->willSeeException(RuntimeException::class, 'Command is running now!');
108106

109107
$this->artisan('icm:generic');
110108
}
@@ -116,8 +114,8 @@ public function it_blocks_if_trying_to_run_another_instance_of_the_command()
116114
*/
117115
public function it_is_releasing_the_lock_after_command_execution()
118116
{
119-
$mutex = Mockery::mock('overload:Illuminated\Console\Mutex');
120-
$mutex->shouldReceive('releaseLock')->withNoArgs()->once();
117+
$mutex = mock('overload:Illuminated\Console\Mutex');
118+
$mutex->expects()->releaseLock();
121119

122120
$command = new GenericCommand;
123121
$command->releaseMutexLock($mutex);

0 commit comments

Comments
 (0)