55use Exception ;
66use PHPUnit \Framework \TestCase ;
77use Qase \PhpCommons \Interfaces \ClientInterface ;
8+ use Qase \PhpCommons \Interfaces \LoggerInterface ;
89use Qase \PhpCommons \Interfaces \StateInterface ;
910use Qase \PhpCommons \Models \Config \QaseConfig ;
1011use Qase \PhpCommons \Reporters \TestOpsReporter ;
@@ -14,12 +15,14 @@ class TestOpsReporterTest extends TestCase
1415{
1516 private $ clientMock ;
1617 private $ stateMock ;
18+ private $ loggerMock ;
1719 private QaseConfig $ config ;
1820
1921 protected function setUp (): void
2022 {
2123 $ this ->clientMock = $ this ->createMock (ClientInterface::class);
2224 $ this ->stateMock = $ this ->createMock (StateInterface::class);
25+ $ this ->loggerMock = $ this ->createMock (LoggerInterface::class);
2326 $ this ->config = $ this ->getConfig ();
2427 }
2528
@@ -30,7 +33,7 @@ public function testStartRunCreatesNewRunIfRunIdIsNull(): void
3033 $ this ->stateMock ->method ('startRun ' )
3134 ->willReturn (123 );
3235
33- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
36+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
3437 $ reporter ->startRun ();
3538
3639 $ this ->assertSame (123 , $ this ->getPrivateProperty ($ reporter , 'runId ' ));
@@ -47,7 +50,7 @@ public function testStartRunThrowsExceptionIfRunNotFound(): void
4750 $ this ->expectException (Exception::class);
4851 $ this ->expectExceptionMessage ('Run with id 123 not found ' );
4952
50- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
53+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
5154 $ reporter ->startRun ();
5255 }
5356
@@ -59,7 +62,7 @@ public function testStartRunUsesExistingRunId(): void
5962 ->with ('TEST_PROJECT ' , 123 )
6063 ->willReturn (true );
6164
62- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
65+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
6366 $ reporter ->startRun ();
6467
6568 $ this ->assertSame (123 , $ this ->getPrivateProperty ($ reporter , 'runId ' ));
@@ -73,7 +76,7 @@ public function testSendResultsClearsResults(): void
7376 ->method ('sendResults ' )
7477 ->with ('TEST_PROJECT ' , 123 , ['result1 ' , 'result2 ' ]);
7578
76- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
79+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
7780 $ reporter ->startRun ();
7881
7982 $ reporter ->addResult ('result1 ' );
@@ -91,7 +94,7 @@ public function testAddResultSendsResultsWhenBatchSizeIsReached(): void
9194 ->method ('sendResults ' )
9295 ->with ('TEST_PROJECT ' , 123 , ['result1 ' , 'result2 ' ]);
9396
94- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
97+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
9598 $ reporter ->startRun ();
9699
97100 $ reporter ->addResult ('result1 ' );
@@ -116,7 +119,7 @@ public function testCompleteRunSendsRemainingResults(): void
116119 return is_callable ($ callback );
117120 }));
118121
119- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
122+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
120123 $ reporter ->startRun ();
121124
122125 $ reporter ->addResult ('result1 ' );
@@ -141,7 +144,7 @@ public function testCompleteRunWithNoResultsDoesNothing(): void
141144 ->method ('completeRun ' )
142145 ->with ($ this ->isType ('callable ' ));
143146
144- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
147+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
145148 $ reporter ->startRun ();
146149 $ reporter ->completeRun ();
147150 }
@@ -155,7 +158,7 @@ public function testCompleteRunWithCompleteIsFalseDoesNotCompleteTestRun(): void
155158 $ this ->clientMock ->expects ($ this ->never ())
156159 ->method ('completeTestRun ' );
157160
158- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
161+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
159162 $ reporter ->startRun ();
160163 $ reporter ->completeRun ();
161164 }
@@ -174,7 +177,7 @@ public function testAddResultFiltersOutExcludedStatuses(): void
174177 $ this ->createResultWithStatus ('failed ' )
175178 ]);
176179
177- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
180+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
178181 $ reporter ->startRun ();
179182
180183 // Add results with different statuses
@@ -206,7 +209,7 @@ public function testAddResultIncludesAllResultsWhenNoFilterConfigured(): void
206209 ]]
207210 );
208211
209- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
212+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
210213 $ reporter ->startRun ();
211214
212215 // Add results with different statuses - all should be included
@@ -230,7 +233,7 @@ public function testAddResultHandlesResultsWithoutStatus(): void
230233 $ this ->createResultWithStatus ('passed ' )
231234 ]);
232235
233- $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock );
236+ $ reporter = new TestOpsReporter ($ this ->clientMock , $ this ->config , $ this ->stateMock , $ this -> loggerMock );
234237 $ reporter ->startRun ();
235238
236239 // Add results - one without status should be included
0 commit comments