From 84c2c0eac89f893dd561a6ea4546f5ee24a38027 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Mar 2026 13:52:11 +0530 Subject: [PATCH 1/2] test: add tests for Gitea comment operations - Implement testCreateComment with PR creation and verification - Implement testUpdateComment with comment modification flow - Add try/finally cleanup to prevent test repository leaks - Remove skipped test markers for createComment and updateComment --- tests/VCS/Adapter/GiteaTest.php | 69 ++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/tests/VCS/Adapter/GiteaTest.php b/tests/VCS/Adapter/GiteaTest.php index 4405bab3..493e33f5 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 @@ -788,7 +821,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->assertNotEmpty($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 From a12ffe2778ce2a56687adfbe0d77cf98f25087b5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 20 Mar 2026 15:25:34 +0530 Subject: [PATCH 2/2] updated with suggestions --- tests/VCS/Adapter/GiteaTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/VCS/Adapter/GiteaTest.php b/tests/VCS/Adapter/GiteaTest.php index 4398c64e..88e75341 100644 --- a/tests/VCS/Adapter/GiteaTest.php +++ b/tests/VCS/Adapter/GiteaTest.php @@ -878,7 +878,7 @@ public function testCreateComment(): void // Test createComment $commentId = $this->vcsAdapter->createComment(self::$owner, $repositoryName, $prNumber, 'Test comment'); - $this->assertNotEmpty($commentId); + $this->assertNotEquals('', $commentId); $this->assertIsString($commentId); $this->assertIsNumeric($commentId);