Skip to content
Open
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
65 changes: 65 additions & 0 deletions tests/Integration/ChatMiscIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,71 @@ public function channelBatchUpdate(): void
self::markTestSkipped('ChannelBatchUpdate is not yet available in the generated SDK');
}

// =========================================================================
// Retention Policy
// =========================================================================

/**
* @test
*/
public function getRetentionPolicy(): void
{
$policyName = 'old-messages';

// Ensure a policy exists before querying
try {
$this->client->setRetentionPolicy(new GeneratedModels\SetRetentionPolicyRequest(
policy: $policyName,
maxAgeHours: 720,
));
} catch (\Exception $e) {
if (str_contains($e->getMessage(), 'not enabled') || str_contains($e->getMessage(), 'retention')) {
self::markTestSkipped('Retention policies are not enabled for this app');
}

throw $e;
}

try {
$resp = $this->client->getRetentionPolicy();
$this->assertResponseSuccess($resp, 'get retention policy');
self::assertNotNull($resp->getData()->policies, 'Policies list should be returned');
self::assertNotEmpty($resp->getData()->policies, 'Should have at least one policy');
} catch (\Exception $e) {
if (str_contains($e->getMessage(), 'not enabled') || str_contains($e->getMessage(), 'retention')) {
self::markTestSkipped('Retention policies are not enabled for this app');
}

throw $e;
} finally {
// Clean up the policy we created
try {
$this->client->deleteRetentionPolicy(new GeneratedModels\DeleteRetentionPolicyRequest(
policy: $policyName,
));
} catch (\Exception $ignore) {
}
}
}

/**
* @test
*/
public function getRetentionPolicyRuns(): void
{
try {
$resp = $this->client->getRetentionPolicyRuns(limit: 10, offset: 0);
$this->assertResponseSuccess($resp, 'get retention policy runs');
self::assertNotNull($resp->getData()->runs, 'Runs list should be returned');
} catch (\Exception $e) {
if (str_contains($e->getMessage(), 'not enabled') || str_contains($e->getMessage(), 'retention')) {
self::markTestSkipped('Retention policies are not enabled for this app');
}

throw $e;
}
}

protected static function sharedUserCount(): int
{
return 2;
Expand Down
Loading