7
7
use Illuminated \Console \Tests \App \Console \Commands \MysqlStrategyCommand ;
8
8
use Illuminated \Console \Tests \App \Console \Commands \NullTimeoutCommand ;
9
9
use Illuminated \Console \Tests \App \Console \Commands \TimeoutCommand ;
10
+ use PHPUnit \Framework \Attributes \PreserveGlobalState ;
11
+ use PHPUnit \Framework \Attributes \RunInSeparateProcess ;
12
+ use PHPUnit \Framework \Attributes \Test ;
10
13
11
14
class WithoutOverlappingTraitTest extends TestCase
12
15
{
13
- /** @test */
14
- public function it_adds_mutex_strategy_which_is_file_by_default ()
16
+ #[Test]
17
+ public function it_adds_mutex_strategy_which_is_file_by_default (): void
15
18
{
16
19
$ this ->assertEquals ('file ' , (new GenericCommand )->getMutexStrategy ());
17
20
}
18
21
19
- /** @test */
20
- public function mutex_strategy_can_be_overloaded_by_protected_field ()
22
+ #[Test]
23
+ public function mutex_strategy_can_be_overloaded_by_protected_field (): void
21
24
{
22
25
$ this ->assertEquals ('mysql ' , (new MysqlStrategyCommand )->getMutexStrategy ());
23
26
}
24
27
25
- /** @test */
26
- public function mutex_strategy_can_be_set_by_the_public_method ()
28
+ #[Test]
29
+ public function mutex_strategy_can_be_set_by_the_public_method (): void
27
30
{
28
31
$ command = new GenericCommand ;
29
32
$ command ->setMutexStrategy ('redis ' );
30
33
31
34
$ this ->assertEquals ('redis ' , $ command ->getMutexStrategy ());
32
35
}
33
36
34
- /** @test */
35
- public function it_adds_mutex_timeout_which_is_zero_by_default ()
37
+ #[Test]
38
+ public function it_adds_mutex_timeout_which_is_zero_by_default (): void
36
39
{
37
40
$ this ->assertEquals (0 , (new GenericCommand )->getMutexTimeout ());
38
41
}
39
42
40
- /** @test */
41
- public function mutex_timeout_can_be_overloaded_by_protected_field ()
43
+ #[Test]
44
+ public function mutex_timeout_can_be_overloaded_by_protected_field (): void
42
45
{
43
46
$ this ->assertEquals (3000 , (new TimeoutCommand )->getMutexTimeout ());
44
47
}
45
48
46
- /** @test */
47
- public function mutex_timeout_can_be_set_to_null_by_protected_field ()
49
+ #[Test]
50
+ public function mutex_timeout_can_be_set_to_null_by_protected_field (): void
48
51
{
49
52
$ this ->assertNull ((new NullTimeoutCommand )->getMutexTimeout ());
50
53
}
51
54
52
- /** @test */
53
- public function mutex_timeout_can_be_set_by_the_public_method ()
55
+ #[Test]
56
+ public function mutex_timeout_can_be_set_by_the_public_method (): void
54
57
{
55
58
$ command = new GenericCommand ;
56
59
$ command ->setMutexTimeout (5000 );
57
60
58
61
$ this ->assertEquals (5000 , $ command ->getMutexTimeout ());
59
62
}
60
63
61
- /** @test */
62
- public function mutex_timeout_can_be_set_to_null_by_the_public_method ()
64
+ #[Test]
65
+ public function mutex_timeout_can_be_set_to_null_by_the_public_method (): void
63
66
{
64
67
$ command = new GenericCommand ;
65
68
$ command ->setMutexTimeout (null );
66
69
67
70
$ this ->assertNull ($ command ->getMutexTimeout ());
68
71
}
69
72
70
- /** @test */
71
- public function it_generates_mutex_name_based_on_the_command_name_and_arguments ()
73
+ #[Test]
74
+ public function it_generates_mutex_name_based_on_the_command_name_and_arguments (): void
72
75
{
73
76
/** @var \Mockery\Mock|\Illuminated\Console\WithoutOverlapping $command */
74
77
$ command = mock (GenericCommand::class)->makePartial ();
@@ -79,12 +82,8 @@ public function it_generates_mutex_name_based_on_the_command_name_and_arguments(
79
82
$ this ->assertEquals ("icmutex-icm:generic- {$ hash }" , $ command ->getMutexName ());
80
83
}
81
84
82
- /**
83
- * @test
84
- * @runInSeparateProcess
85
- * @preserveGlobalState disabled
86
- */
87
- public function it_allows_to_run_command_if_there_is_no_other_running_instances ()
85
+ #[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false )]
86
+ public function it_allows_to_run_command_if_there_is_no_other_running_instances (): void
88
87
{
89
88
$ mutex = mock ('overload:Illuminated\Console\Mutex ' );
90
89
$ mutex ->expects ('acquireLock ' )->with (0 )->andReturn (true );
@@ -93,12 +92,8 @@ public function it_allows_to_run_command_if_there_is_no_other_running_instances(
93
92
$ this ->artisan ('icm:generic ' );
94
93
}
95
94
96
- /**
97
- * @test
98
- * @runInSeparateProcess
99
- * @preserveGlobalState disabled
100
- */
101
- public function it_blocks_if_trying_to_run_another_instance_of_the_command ()
95
+ #[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false )]
96
+ public function it_blocks_if_trying_to_run_another_instance_of_the_command (): void
102
97
{
103
98
$ this ->expectException (MutexRuntimeException::class);
104
99
$ this ->expectExceptionMessage ('Command is running now! ' );
@@ -109,12 +104,8 @@ public function it_blocks_if_trying_to_run_another_instance_of_the_command()
109
104
$ this ->artisan ('icm:generic ' );
110
105
}
111
106
112
- /**
113
- * @test
114
- * @runInSeparateProcess
115
- * @preserveGlobalState disabled
116
- */
117
- public function it_is_releasing_the_lock_after_command_execution ()
107
+ #[Test] #[RunInSeparateProcess] #[PreserveGlobalState(false )]
108
+ public function it_is_releasing_the_lock_after_command_execution (): void
118
109
{
119
110
/** @var \Mockery\Mock|\Illuminated\Console\Mutex $mutex */
120
111
$ mutex = mock ('overload:Illuminated\Console\Mutex ' );
0 commit comments