diff --git a/tests/VCS/Adapter/GiteaTest.php b/tests/VCS/Adapter/GiteaTest.php index bed2ff4c..88e75341 100644 --- a/tests/VCS/Adapter/GiteaTest.php +++ b/tests/VCS/Adapter/GiteaTest.php @@ -505,7 +505,40 @@ public function testGenerateCloneCommandWithTag(): void public function testUpdateComment(): void { - $this->markTestSkipped('Will be implemented in follow-up PR'); + $repositoryName = 'test-update-comment-' . \uniqid(); + $this->vcsAdapter->createRepository(self::$owner, $repositoryName, false); + + try { + $this->vcsAdapter->createFile(self::$owner, $repositoryName, 'README.md', '# Test'); + $this->vcsAdapter->createBranch(self::$owner, $repositoryName, 'test-branch', 'main'); + $this->vcsAdapter->createFile(self::$owner, $repositoryName, 'test.txt', 'test', 'Add test', 'test-branch'); + + // Create PR + $pr = $this->vcsAdapter->createPullRequest( + self::$owner, + $repositoryName, + 'Test PR', + 'test-branch', + 'main' + ); + + $prNumber = $pr['number'] ?? 0; + $this->assertGreaterThan(0, $prNumber); + + // Create comment + $commentId = $this->vcsAdapter->createComment(self::$owner, $repositoryName, $prNumber, 'Original comment'); + + // Test updateComment + $updatedCommentId = $this->vcsAdapter->updateComment(self::$owner, $repositoryName, (int)$commentId, 'Updated comment'); + + $this->assertSame($commentId, $updatedCommentId); + + // Verify comment was updated + $finalComment = $this->vcsAdapter->getComment(self::$owner, $repositoryName, $commentId); + $this->assertSame('Updated comment', $finalComment); + } finally { + $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); + } } public function testGetCommit(): void @@ -822,7 +855,39 @@ public function testGetPullRequestFromBranchNoPR(): void public function testCreateComment(): void { - $this->markTestSkipped('Will be implemented in follow-up PR'); + $repositoryName = 'test-create-comment-' . \uniqid(); + $this->vcsAdapter->createRepository(self::$owner, $repositoryName, false); + + try { + $this->vcsAdapter->createFile(self::$owner, $repositoryName, 'README.md', '# Test'); + $this->vcsAdapter->createBranch(self::$owner, $repositoryName, 'test-branch', 'main'); + $this->vcsAdapter->createFile(self::$owner, $repositoryName, 'test.txt', 'test', 'Add test', 'test-branch'); + + // Create PR + $pr = $this->vcsAdapter->createPullRequest( + self::$owner, + $repositoryName, + 'Test PR', + 'test-branch', + 'main' + ); + + $prNumber = $pr['number'] ?? 0; + $this->assertGreaterThan(0, $prNumber); + + // Test createComment + $commentId = $this->vcsAdapter->createComment(self::$owner, $repositoryName, $prNumber, 'Test comment'); + + $this->assertNotEquals('', $commentId); + $this->assertIsString($commentId); + $this->assertIsNumeric($commentId); + + // Verify comment was created + $retrievedComment = $this->vcsAdapter->getComment(self::$owner, $repositoryName, $commentId); + $this->assertSame('Test comment', $retrievedComment); + } finally { + $this->vcsAdapter->deleteRepository(self::$owner, $repositoryName); + } } public function testCreateFile(): void