@@ -19,6 +19,27 @@ class MutexTest extends TestCase
19
19
20
20
protected Mutex $ mutex ;
21
21
22
+ protected function setUp (): void
23
+ {
24
+ $ this ->command = new class () extends Command
25
+ {
26
+ public int $ ran = 0 ;
27
+
28
+ public function handle (): int
29
+ {
30
+ ++$ this ->ran ;
31
+
32
+ return self ::SUCCESS ;
33
+ }
34
+ };
35
+
36
+ $ this ->mutex = m::mock (Mutex::class);
37
+
38
+ $ container = Container::getInstance ();
39
+ $ container ->instance (Mutex::class, $ this ->mutex );
40
+ $ this ->command ->setLaravel ($ container );
41
+ }
42
+
22
43
public function testCanRunIsolatedCommandIfNotBlocked ()
23
44
{
24
45
$ this ->mutex ->shouldReceive ('create ' )
@@ -74,31 +95,10 @@ public function testCanRunCommandAgainNonAutomated()
74
95
$ this ->assertEquals (1 , $ this ->command ->ran );
75
96
}
76
97
77
- protected function setUp (): void
78
- {
79
- $ this ->command = new class extends Command
80
- {
81
- public int $ ran = 0 ;
82
-
83
- public function handle (): int
84
- {
85
- $ this ->ran ++;
86
-
87
- return self ::SUCCESS ;
88
- }
89
- };
90
-
91
- $ this ->mutex = m::mock (Mutex::class);
92
-
93
- $ container = Container::getInstance ();
94
- $ container ->instance (Mutex::class, $ this ->mutex );
95
- $ this ->command ->setLaravel ($ container );
96
- }
97
-
98
98
protected function runCommand ($ withIsolated = true )
99
99
{
100
100
$ input = new ArrayInput (['-- ' . Options::ISOLATED => $ withIsolated ]);
101
- $ output = new NullOutput ;
101
+ $ output = new NullOutput () ;
102
102
103
103
$ this ->command ->run ($ input , $ output );
104
104
}
0 commit comments