7
7
use Laminas \AutomaticReleases \Git \HasTag ;
8
8
use Laminas \AutomaticReleases \Git \HasTagViaConsole ;
9
9
use PHPUnit \Framework \TestCase ;
10
+ use Psl \Env ;
11
+ use Psl \Filesystem ;
12
+ use Psl \Shell ;
10
13
11
14
use function array_map ;
12
- use function Psl \Env \temp_dir ;
13
- use function Psl \Filesystem \create_directory ;
14
- use function Psl \Filesystem \create_temporary_file ;
15
- use function Psl \Filesystem \delete_file ;
16
- use function Psl \Shell \execute ;
17
15
use function sprintf ;
18
16
19
17
/** @covers \Laminas\AutomaticReleases\Git\HasTagViaConsole */
@@ -27,17 +25,17 @@ protected function setUp(): void
27
25
{
28
26
parent ::setUp ();
29
27
30
- $ this ->repository = create_temporary_file (temp_dir (), 'HasTagViaConsoleRepository ' );
28
+ $ this ->repository = Filesystem \ create_temporary_file (Env \ temp_dir (), 'HasTagViaConsoleRepository ' );
31
29
32
30
$ this ->hasTag = new HasTagViaConsole ();
33
31
34
- delete_file ($ this ->repository );
35
- create_directory ($ this ->repository );
32
+ Filesystem \ delete_file ($ this ->repository );
33
+ Filesystem \ create_directory ($ this ->repository );
36
34
37
- execute ('git ' , ['init ' ], $ this ->repository );
35
+ Shell \ execute ('git ' , ['init ' ], $ this ->repository );
38
36
39
- execute (
'git ' , [
'config ' ,
'user.email ' ,
'[email protected] ' ],
$ this ->
repository );
40
- execute ('git ' , ['config ' , 'user.name ' , 'Just Me ' ], $ this ->repository );
37
+ Shell \ execute(
'git ' , [
'config ' ,
'user.email ' ,
'[email protected] ' ],
$ this ->
repository );
38
+ Shell \ execute ('git ' , ['config ' , 'user.name ' , 'Just Me ' ], $ this ->repository );
41
39
42
40
array_map (fn (string $ tag ) => $ this ->createTag ($ tag ), [
43
41
'1.0.0 ' ,
@@ -47,29 +45,35 @@ protected function setUp(): void
47
45
48
46
private function createTag (string $ tag ): void
49
47
{
50
- execute ('git ' , ['commit ' , '--allow-empty ' , '-m ' , 'a commit for version ' . $ tag ], $ this ->repository );
51
- execute ('git ' , ['tag ' , '-a ' , $ tag , '-m ' , 'version ' . $ tag ], $ this ->repository );
48
+ Shell \ execute ('git ' , ['commit ' , '--allow-empty ' , '-m ' , 'a commit for version ' . $ tag ], $ this ->repository );
49
+ Shell \ execute ('git ' , ['tag ' , '-a ' , $ tag , '-m ' , 'version ' . $ tag ], $ this ->repository );
52
50
}
53
51
54
- /** @param non-empty-string $repository */
52
+ /**
53
+ * @param non-empty-string $repository
54
+ * @param non-empty-string $tag
55
+ */
55
56
private function assertGitTagExists (string $ repository , string $ tag ): void
56
57
{
57
58
self ::assertTrue (($ this ->hasTag )($ repository , $ tag ), sprintf ('Failed asserting git tag "%s" exists. ' , $ tag ));
58
59
}
59
60
60
- /** @param non-empty-string $repository */
61
+ /**
62
+ * @param non-empty-string $repository
63
+ * @param non-empty-string $tag
64
+ */
61
65
private function assertGitTagMissing (string $ repository , string $ tag ): void
62
66
{
63
67
self ::assertFalse (($ this ->hasTag )($ repository , $ tag ), sprintf ('Failed asserting git tag "%s" is missing. ' , $ tag ));
64
68
}
65
69
66
70
public function testHasTag (): void
67
71
{
68
- self :: assertGitTagExists ($ this ->repository , '1.0.0 ' );
72
+ $ this -> assertGitTagExists ($ this ->repository , '1.0.0 ' );
69
73
}
70
74
71
75
public function testHasTagMissing (): void
72
76
{
73
- self :: assertGitTagMissing ($ this ->repository , '10.0.0 ' );
77
+ $ this -> assertGitTagMissing ($ this ->repository , '10.0.0 ' );
74
78
}
75
79
}
0 commit comments