3
3
namespace Illuminated \Console \ConsoleMutex \Tests ;
4
4
5
5
use GenericCommand ;
6
- use Mockery ;
7
6
use MysqlStrategyCommand ;
8
7
use NullTimeoutCommand ;
9
8
use RuntimeException ;
@@ -71,9 +70,9 @@ public function mutex_timeout_can_be_set_to_null_by_the_public_method()
71
70
/** @test */
72
71
public function it_generates_mutex_name_based_on_the_command_name_and_arguments ()
73
72
{
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 ' ]);
77
76
78
77
$ md5 = md5 (json_encode (['foo ' => 'bar ' , 'baz ' => 'faz ' ]));
79
78
$ 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(
86
85
*/
87
86
public function it_allows_to_run_command_if_there_is_no_other_running_instances ()
88
87
{
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 ();
92
91
93
92
$ this ->artisan ('icm:generic ' );
94
93
}
@@ -100,11 +99,10 @@ public function it_allows_to_run_command_if_there_is_no_other_running_instances(
100
99
*/
101
100
public function it_blocks_if_trying_to_run_another_instance_of_the_command ()
102
101
{
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 );
105
104
106
- $ this ->expectException (RuntimeException::class);
107
- $ this ->expectExceptionMessage ('Command is running now! ' );
105
+ $ this ->willSeeException (RuntimeException::class, 'Command is running now! ' );
108
106
109
107
$ this ->artisan ('icm:generic ' );
110
108
}
@@ -116,8 +114,8 @@ public function it_blocks_if_trying_to_run_another_instance_of_the_command()
116
114
*/
117
115
public function it_is_releasing_the_lock_after_command_execution ()
118
116
{
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 ();
121
119
122
120
$ command = new GenericCommand ;
123
121
$ command ->releaseMutexLock ($ mutex );
0 commit comments