44
55use BrainMaestro \GitHooks \Commands \AddCommand ;
66use BrainMaestro \GitHooks \Hook ;
7+ use PHPUnit \Framework \Attributes \Group ;
78use Symfony \Component \Console \Tester \CommandTester ;
89use Symfony \Component \Console \Output \OutputInterface ;
910use PHPUnit \Framework \Attributes \Test ;
@@ -17,6 +18,7 @@ public function init()
1718 $ this ->commandTester = new CommandTester (new AddCommand ());
1819 }
1920
21+ /** @test */
2022 #[Test]
2123 public function it_adds_hooks_that_do_not_already_exist ()
2224 {
@@ -27,6 +29,7 @@ public function it_adds_hooks_that_do_not_already_exist()
2729 }
2830 }
2931
32+ /** @test */
3033 #[Test]
3134 public function it_doesnt_allow_to_add_custom_hooks_by_default ()
3235 {
@@ -44,6 +47,7 @@ public function it_doesnt_allow_to_add_custom_hooks_by_default()
4447 );
4548 }
4649
50+ /** @test */
4751 #[Test]
4852 public function it_allows_to_add_custom_hooks_specified_in_config_section ()
4953 {
@@ -69,6 +73,7 @@ public function it_allows_to_add_custom_hooks_specified_in_config_section()
6973 );
7074 }
7175
76+ /** @test */
7277 #[Test]
7378 public function it_adds_shebang_to_hooks_on_windows ()
7479 {
@@ -87,6 +92,7 @@ public function it_adds_shebang_to_hooks_on_windows()
8792 }
8893 }
8994
95+ /** @test */
9096 #[Test]
9197 public function it_does_not_add_hooks_that_already_exist ()
9298 {
@@ -100,6 +106,7 @@ public function it_does_not_add_hooks_that_already_exist()
100106 $ this ->assertStringContainsString ('No hooks were added. Try updating ' , $ this ->commandTester ->getDisplay ());
101107 }
102108
109+ /** @test */
103110 #[Test]
104111 public function it_detects_existing_correct_hooks ()
105112 {
@@ -120,6 +127,7 @@ public function it_detects_existing_correct_hooks()
120127 self ::$ hooks = $ originalHooks ;
121128 }
122129
130+ /** @test */
123131 #[Test]
124132 public function it_overrides_hooks_that_already_exist ()
125133 {
@@ -131,6 +139,7 @@ public function it_overrides_hooks_that_already_exist()
131139 }
132140 }
133141
142+ /** @test */
134143 #[Test]
135144 public function it_correctly_creates_the_hook_lock_file ()
136145 {
@@ -146,6 +155,8 @@ public function it_correctly_creates_the_hook_lock_file()
146155 * @test
147156 * @group lock-dir
148157 */
158+ #[Test]
159+ #[Group('lock-dir ' )]
149160 public function it_correctly_creates_the_hook_lock_file_in_lock_dir ()
150161 {
151162 $ lockDir = 'lock-dir ' ;
@@ -163,6 +174,7 @@ public function it_correctly_creates_the_hook_lock_file_in_lock_dir()
163174 self ::rmdir ('../ ' . $ lockDir );
164175 }
165176
177+ /** @test */
166178 #[Test]
167179 public function it_does_not_create_the_hook_lock_file_if_the_no_lock_option_is_passed ()
168180 {
@@ -173,6 +185,7 @@ public function it_does_not_create_the_hook_lock_file_if_the_no_lock_option_is_p
173185 $ this ->assertFileDoesNotExist (Hook::LOCK_FILE );
174186 }
175187
188+ /** @test */
176189 #[Test]
177190 public function it_does_not_ignore_the_hook_lock_file ()
178191 {
@@ -183,6 +196,7 @@ public function it_does_not_ignore_the_hook_lock_file()
183196 $ this ->assertFalse (strpos (file_get_contents ('.gitignore ' ), Hook::LOCK_FILE ));
184197 }
185198
199+ /** @test */
186200 #[Test]
187201 public function it_ignores_the_hook_lock_file_if_the_ignore_lock_option_is_passed ()
188202 {
@@ -192,6 +206,7 @@ public function it_ignores_the_hook_lock_file_if_the_ignore_lock_option_is_passe
192206 $ this ->assertTrue (strpos (file_get_contents ('.gitignore ' ), Hook::LOCK_FILE ) !== false );
193207 }
194208
209+ /** @test */
195210 #[Test]
196211 public function it_does_not_ignore_the_hook_lock_file_if_it_is_already_ignored ()
197212 {
@@ -202,6 +217,7 @@ public function it_does_not_ignore_the_hook_lock_file_if_it_is_already_ignored()
202217 $ this ->assertTrue (strpos (file_get_contents ('.gitignore ' ), Hook::LOCK_FILE ) !== false );
203218 }
204219
220+ /** @test */
205221 #[Test]
206222 public function it_uses_a_different_git_path_if_specified ()
207223 {
@@ -217,6 +233,7 @@ public function it_uses_a_different_git_path_if_specified()
217233 }
218234 }
219235
236+ /** @test */
220237 #[Test]
221238 public function it_does_not_create_a_lock_file_when_no_hooks_were_added ()
222239 {
@@ -229,6 +246,7 @@ public function it_does_not_create_a_lock_file_when_no_hooks_were_added()
229246 }
230247 }
231248
249+ /** @test */
232250 #[Test]
233251 public function it_create_git_hooks_path_when_hooks_dir_not_exists ()
234252 {
@@ -243,6 +261,7 @@ public function it_create_git_hooks_path_when_hooks_dir_not_exists()
243261 }
244262 }
245263
264+ /** @test */
246265 #[Test]
247266 public function it_adds_win_bash_compat_if_the_force_windows_option_is_passed ()
248267 {
@@ -257,6 +276,7 @@ public function it_adds_win_bash_compat_if_the_force_windows_option_is_passed()
257276 }
258277 }
259278
279+ /** @test */
260280 #[Test]
261281 public function it_handles_commands_defined_in_an_array ()
262282 {
@@ -280,6 +300,7 @@ public function it_handles_commands_defined_in_an_array()
280300 }
281301
282302
303+ /** @test */
283304 #[Test]
284305 public function it_uses_commands_sequence_for_configured_hooks_only ()
285306 {
@@ -315,6 +336,7 @@ public function it_uses_commands_sequence_for_configured_hooks_only()
315336 $ this ->assertStringContainsString ($ expected , $ content );
316337 }
317338
339+ /** @test */
318340 #[Test]
319341 public function it_adds_global_git_hooks ()
320342 {
@@ -342,6 +364,7 @@ public function it_adds_global_git_hooks()
342364 $ this ->assertEquals ($ hookDir , global_hook_dir ());
343365 }
344366
367+ /** @test */
345368 #[Test]
346369 public function it_adds_global_git_hooks_and_shows_previous_global_dir ()
347370 {
@@ -371,6 +394,7 @@ public function it_adds_global_git_hooks_and_shows_previous_global_dir()
371394 $ this ->assertEquals ($ hookDir , global_hook_dir ());
372395 }
373396
397+ /** @test */
374398 #[Test]
375399 public function it_adds_global_git_hooks_and_does_not_change_global_dir_if_it_matches_new_value ()
376400 {
@@ -399,6 +423,7 @@ public function it_adds_global_git_hooks_and_does_not_change_global_dir_if_it_ma
399423 $ this ->assertEquals ($ hookDir , global_hook_dir ());
400424 }
401425
426+ /** @test */
402427 #[Test]
403428 public function it_falls_back_to_composer_home_if_no_global_hook_dir_is_provided ()
404429 {
@@ -431,6 +456,7 @@ public function it_falls_back_to_composer_home_if_no_global_hook_dir_is_provided
431456 $ this ->assertEquals ($ hookDir , global_hook_dir ());
432457 }
433458
459+ /** @test */
434460 #[Test]
435461 public function it_fails_if_global_hook_dir_is_missing ()
436462 {
@@ -450,6 +476,7 @@ public function it_fails_if_global_hook_dir_is_missing()
450476 );
451477 }
452478
479+ /** @test */
453480 #[Test]
454481 public function it_adds_hooks_correctly_in_a_git_worktree ()
455482 {
0 commit comments