Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 67 additions & 2 deletions tests/VCS/Adapter/GiteaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading