@@ -125,7 +125,9 @@ public function testHiddenAuthorConfiguration()
125125 $ config = new Configuration (['hiddenAuthor ' => false ]);
126126 // Author should not be hidden when set to false
127127 $ this ->assertFalse ($ config ->isHiddenAuthor ());
128-
128+ }
129+
130+ /** @test */
129131 public function testAzureDevOpsHttpsUrlPatternMatching ()
130132 {
131133 // Test Azure DevOps HTTPS URL pattern directly
@@ -248,4 +250,112 @@ public function testAzureDevOpsHostNormalization()
248250 // Verify host was normalized to dev.azure.com
249251 $ this ->assertEquals ('dev.azure.com ' , $ remote ['host ' ]);
250252 }
253+
254+ /** @test */
255+ public function testRunHookWithStringCommand ()
256+ {
257+ $ config = new Configuration ();
258+
259+ // Use reflection to test the runHook method
260+ $ class = new \ReflectionClass ($ config );
261+ $ method = $ class ->getMethod ('runHook ' );
262+ $ method ->setAccessible (true );
263+
264+ // Test with a simple string command
265+ // We can't easily test system() output, but we can test it doesn't throw an error
266+ ob_start ();
267+ $ method ->invoke ($ config , 'echo "test" ' );
268+ $ output = ob_get_clean ();
269+
270+ // If we got here without exception, the method works
271+ $ this ->assertTrue (true );
272+ }
273+
274+ /** @test */
275+ public function testRunHookWithPipeCommand ()
276+ {
277+ $ config = new Configuration ();
278+
279+ // Use reflection to test the runHook method
280+ $ class = new \ReflectionClass ($ config );
281+ $ method = $ class ->getMethod ('runHook ' );
282+ $ method ->setAccessible (true );
283+
284+ // Test with a command that uses pipe
285+ ob_start ();
286+ $ method ->invoke ($ config , 'echo "test" | cat ' );
287+ $ output = ob_get_clean ();
288+
289+ // If we got here without exception, the method works with pipes
290+ $ this ->assertTrue (true );
291+ }
292+
293+ /** @test */
294+ public function testRunHookWithCallable ()
295+ {
296+ $ config = new Configuration ();
297+
298+ // Use reflection to test the runHook method
299+ $ class = new \ReflectionClass ($ config );
300+ $ method = $ class ->getMethod ('runHook ' );
301+ $ method ->setAccessible (true );
302+
303+ // Test with a callable
304+ $ called = false ;
305+ $ hook = function () use (&$ called ) {
306+ $ called = true ;
307+ };
308+
309+ $ method ->invoke ($ config , $ hook );
310+
311+ // Verify the callable was executed
312+ $ this ->assertTrue ($ called );
313+ }
314+
315+ /** @test */
316+ public function testRunHookWithNull ()
317+ {
318+ $ config = new Configuration ();
319+
320+ // Use reflection to test the runHook method
321+ $ class = new \ReflectionClass ($ config );
322+ $ method = $ class ->getMethod ('runHook ' );
323+ $ method ->setAccessible (true );
324+
325+ // Test with null - should not throw exception
326+ $ method ->invoke ($ config , null );
327+
328+ // If we got here without exception, it handled null correctly
329+ $ this ->assertTrue (true );
330+ }
331+
332+ /** @test */
333+ public function testPreRunHook ()
334+ {
335+ $ called = false ;
336+ $ hook = function () use (&$ called ) {
337+ $ called = true ;
338+ };
339+
340+ $ config = new Configuration (['preRun ' => $ hook ]);
341+ $ config ->preRun ();
342+
343+ // Verify the preRun hook was executed
344+ $ this ->assertTrue ($ called );
345+ }
346+
347+ /** @test */
348+ public function testPostRunHook ()
349+ {
350+ $ called = false ;
351+ $ hook = function () use (&$ called ) {
352+ $ called = true ;
353+ };
354+
355+ $ config = new Configuration (['postRun ' => $ hook ]);
356+ $ config ->postRun ();
357+
358+ // Verify the postRun hook was executed
359+ $ this ->assertTrue ($ called );
360+ }
251361}
0 commit comments