@@ -365,12 +365,87 @@ public function testUpdateComment(): void
365365
366366 public function testGetCommit (): void
367367 {
368- $ this ->markTestSkipped ('Will be implemented in follow-up PR ' );
368+ $ repositoryName = 'test-get-commit- ' . \uniqid ();
369+ $ this ->vcsAdapter ->createRepository (self ::$ owner , $ repositoryName , false );
370+
371+ $ customMessage = 'Test commit message ' ;
372+ $ this ->vcsAdapter ->createFile (self ::$ owner , $ repositoryName , 'README.md ' , '# Test Commit ' , $ customMessage );
373+
374+ $ latestCommit = $ this ->vcsAdapter ->getLatestCommit (self ::$ owner , $ repositoryName , 'main ' );
375+ $ commitHash = $ latestCommit ['commitHash ' ];
376+
377+ $ result = $ this ->vcsAdapter ->getCommit (self ::$ owner , $ repositoryName , $ commitHash );
378+
379+ $ this ->assertIsArray ($ result );
380+ $ this ->assertArrayHasKey ('commitHash ' , $ result );
381+ $ this ->assertArrayHasKey ('commitMessage ' , $ result );
382+ $ this ->assertArrayHasKey ('commitAuthor ' , $ result );
383+ $ this ->assertArrayHasKey ('commitUrl ' , $ result );
384+ $ this ->assertArrayHasKey ('commitAuthorAvatar ' , $ result );
385+ $ this ->assertArrayHasKey ('commitAuthorUrl ' , $ result );
386+
387+ $ this ->assertSame ($ commitHash , $ result ['commitHash ' ]);
388+ $ this ->assertStringContainsString ($ customMessage , $ result ['commitMessage ' ]);
389+ $ this ->assertNotEmpty ($ result ['commitAuthor ' ]);
390+ $ this ->assertNotEmpty ($ result ['commitUrl ' ]);
391+
392+ $ this ->vcsAdapter ->deleteRepository (self ::$ owner , $ repositoryName );
369393 }
370394
371395 public function testGetLatestCommit (): void
372396 {
373- $ this ->markTestSkipped ('Will be implemented in follow-up PR ' );
397+ $ repositoryName = 'test-get-latest-commit- ' . \uniqid ();
398+ $ this ->vcsAdapter ->createRepository (self ::$ owner , $ repositoryName , false );
399+
400+ $ firstMessage = 'First commit ' ;
401+ $ secondMessage = 'Second commit ' ;
402+ $ this ->vcsAdapter ->createFile (self ::$ owner , $ repositoryName , 'README.md ' , '# Test ' , $ firstMessage );
403+ $ this ->vcsAdapter ->createFile (self ::$ owner , $ repositoryName , 'test.txt ' , 'test content ' , $ secondMessage );
404+
405+ $ result = $ this ->vcsAdapter ->getLatestCommit (self ::$ owner , $ repositoryName , 'main ' );
406+
407+ $ this ->assertIsArray ($ result );
408+ $ this ->assertArrayHasKey ('commitHash ' , $ result );
409+ $ this ->assertArrayHasKey ('commitMessage ' , $ result );
410+ $ this ->assertArrayHasKey ('commitAuthor ' , $ result );
411+ $ this ->assertArrayHasKey ('commitUrl ' , $ result );
412+ $ this ->assertArrayHasKey ('commitAuthorAvatar ' , $ result );
413+ $ this ->assertArrayHasKey ('commitAuthorUrl ' , $ result );
414+
415+ $ this ->assertNotEmpty ($ result ['commitHash ' ]);
416+ $ this ->assertStringContainsString ($ secondMessage , $ result ['commitMessage ' ]);
417+ $ this ->assertNotEmpty ($ result ['commitAuthor ' ]);
418+ $ this ->assertNotEmpty ($ result ['commitUrl ' ]);
419+
420+ $ this ->vcsAdapter ->deleteRepository (self ::$ owner , $ repositoryName );
421+ }
422+
423+ public function testGetCommitWithInvalidSha (): void
424+ {
425+ $ repositoryName = 'test-get-commit-invalid- ' . \uniqid ();
426+ $ this ->vcsAdapter ->createRepository (self ::$ owner , $ repositoryName , false );
427+ $ this ->vcsAdapter ->createFile (self ::$ owner , $ repositoryName , 'README.md ' , '# Test ' );
428+
429+ try {
430+ $ this ->expectException (\Exception::class);
431+ $ this ->vcsAdapter ->getCommit (self ::$ owner , $ repositoryName , 'invalid-sha-12345 ' );
432+ } finally {
433+ $ this ->vcsAdapter ->deleteRepository (self ::$ owner , $ repositoryName );
434+ }
435+ }
436+
437+ public function testGetLatestCommitWithInvalidBranch (): void
438+ {
439+ $ repositoryName = 'test-get-latest-commit-invalid- ' . \uniqid ();
440+ $ this ->vcsAdapter ->createRepository (self ::$ owner , $ repositoryName , false );
441+ $ this ->vcsAdapter ->createFile (self ::$ owner , $ repositoryName , 'README.md ' , '# Test ' );
442+
443+ try {
444+ $ this ->expectException (\Exception::class);
445+ $ this ->vcsAdapter ->getLatestCommit (self ::$ owner , $ repositoryName , 'non-existing-branch ' );
446+ } finally {
447+ $ this ->vcsAdapter ->deleteRepository (self ::$ owner , $ repositoryName );
448+ }
374449 }
375450
376451 public function testGetEvent (): void
0 commit comments