diff --git a/tests/Integration/ChatMiscIntegrationTest.php b/tests/Integration/ChatMiscIntegrationTest.php index 26e3853..55ff34f 100644 --- a/tests/Integration/ChatMiscIntegrationTest.php +++ b/tests/Integration/ChatMiscIntegrationTest.php @@ -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;