File tree Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Expand file tree Collapse file tree 5 files changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,14 @@ public function __construct(array $options)
41
41
/**
42
42
* Return a option value
43
43
*
44
- * @template T
45
- * @param string $name
46
- * @param T $default
47
- * @return T|null
44
+ * @template ProvidedDefault
45
+ * @param string $name
46
+ * @param ProvidedDefault $default
47
+ * @return ProvidedDefault|mixed
48
48
*/
49
49
public function get (string $ name , $ default = null )
50
50
{
51
- return isset ( $ this ->options [$ name ]) ? $ this -> options [ $ name ] : $ default ;
51
+ return $ this ->options [$ name ] ?? $ default ;
52
52
}
53
53
54
54
/**
Original file line number Diff line number Diff line change @@ -35,21 +35,21 @@ class TestCoverage implements Action
35
35
*
36
36
* @var string
37
37
*/
38
- private $ cloverXmlFile ;
38
+ private string $ cloverXmlFile ;
39
39
40
40
/**
41
41
* Path to PHPUnit
42
42
*
43
43
* @var string
44
44
*/
45
- private $ phpUnit ;
45
+ private string $ phpUnit ;
46
46
47
47
/**
48
48
* Minimum coverage in percent
49
49
*
50
50
* @var int
51
51
*/
52
- private $ minCoverage ;
52
+ private int $ minCoverage ;
53
53
54
54
/**
55
55
* Executes the action.
Original file line number Diff line number Diff line change @@ -36,9 +36,9 @@ class PrepareCommitMsg extends Hook
36
36
protected $ hook = Hooks::PREPARE_COMMIT_MSG ;
37
37
38
38
/**
39
- * @var string|null
39
+ * @var string
40
40
*/
41
- private ? string $ commentChar ;
41
+ private string $ commentChar ;
42
42
43
43
/**
44
44
* Path to commit message file
Original file line number Diff line number Diff line change 15
15
use PHPUnit \Framework \MockObject \MockBuilder ;
16
16
use SebastianFeldmann \Git \Operator \Diff ;
17
17
use SebastianFeldmann \Git \Operator \Index ;
18
+ use SebastianFeldmann \Git \Operator \Config ;
18
19
use SebastianFeldmann \Git \Operator \Info ;
19
20
use SebastianFeldmann \Git \Operator \Log ;
20
21
use SebastianFeldmann \Git \Repository ;
@@ -98,7 +99,6 @@ public function createGitDiffOperator(array $changedFiles = []): Diff
98
99
/**
99
100
* Create log operator mock
100
101
*
101
- * @param array $changedFiles
102
102
* @return \SebastianFeldmann\Git\Operator\Log&\PHPUnit\Framework\MockObject\MockObject
103
103
*/
104
104
public function createGitLogOperator (): Log
@@ -127,6 +127,16 @@ public function createGitIndexOperator(array $stagedFiles = []): Index
127
127
return $ operator ;
128
128
}
129
129
130
+ /**
131
+ * Create config operator mock
132
+ *
133
+ * @return \SebastianFeldmann\Git\Operator\Config&\PHPUnit\Framework\MockObject\MockObject
134
+ */
135
+ public function createGitConfigOperator (): Config
136
+ {
137
+ return $ this ->getMockBuilder (Config::class)->disableOriginalConstructor ()->getMock ();
138
+ }
139
+
130
140
/**
131
141
* @param $type
132
142
* @return \PHPUnit\Framework\MockObject\MockBuilder
Original file line number Diff line number Diff line change @@ -73,9 +73,13 @@ public function testRunHookNoMessageException(): void
73
73
{
74
74
$ this ->expectException (Exception::class);
75
75
76
+ $ repo = $ this ->createRepositoryMock ();
77
+ $ configOp = $ this ->createGitConfigOperator ();
78
+ $ configOp ->method ('getSafely ' )->willReturn ('# ' );
79
+ $ repo ->method ('getConfigOperator ' )->willReturn ($ configOp );
80
+
76
81
$ io = $ this ->createIOMock ();
77
82
$ config = $ this ->createConfigMock ();
78
- $ repo = $ this ->createRepositoryMock ();
79
83
$ hookConfig = $ this ->createHookConfigMock ();
80
84
$ actionConfig = $ this ->createActionConfigMock ();
81
85
$ actionConfig ->method ('getAction ' )->willReturn (Prepare::class);
You can’t perform that action at this time.
0 commit comments