From c11684615fdd0b8f997d4be6aebb67420ff6e77c Mon Sep 17 00:00:00 2001 From: Faiz Shaikh Date: Mon, 23 Mar 2026 17:01:19 +0100 Subject: [PATCH 1/4] test: add retention policy endpoint tests Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/Integration/ChatMiscIntegrationTest.php | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tests/Integration/ChatMiscIntegrationTest.php b/tests/Integration/ChatMiscIntegrationTest.php index 26e3853..d31a00e 100644 --- a/tests/Integration/ChatMiscIntegrationTest.php +++ b/tests/Integration/ChatMiscIntegrationTest.php @@ -640,6 +640,96 @@ public function channelBatchUpdate(): void self::markTestSkipped('ChannelBatchUpdate is not yet available in the generated SDK'); } + // ========================================================================= + // Retention Policy + // ========================================================================= + + /** + * @test + */ + public function setRetentionPolicy(): string + { + try { + $resp = $this->client->setRetentionPolicy(new GeneratedModels\SetRetentionPolicyRequest( + policy: 'old-messages', + maxAgeHours: 720, + )); + $this->assertResponseSuccess($resp, 'set retention policy'); + self::assertNotNull($resp->getData()->policy, 'Policy 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; + } + + return 'old-messages'; + } + + /** + * @test + * @depends setRetentionPolicy + */ + public function getRetentionPolicy(string $policyName): string + { + 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; + } + + return $policyName; + } + + /** + * @test + * @depends getRetentionPolicy + */ + public function getRetentionPolicyRuns(string $policyName): string + { + 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; + } + + return $policyName; + } + + /** + * @test + * @depends getRetentionPolicyRuns + */ + public function deleteRetentionPolicy(string $policyName): void + { + try { + $resp = $this->client->deleteRetentionPolicy(new GeneratedModels\DeleteRetentionPolicyRequest( + policy: $policyName, + )); + $this->assertResponseSuccess($resp, 'delete retention 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; + } + } + protected static function sharedUserCount(): int { return 2; From ce5f27c73276db66458dff2caca45b4843dbc9c8 Mon Sep 17 00:00:00 2001 From: Faiz Shaikh Date: Mon, 23 Mar 2026 17:23:41 +0100 Subject: [PATCH 2/4] test: remove retention policy creation/update tests Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/Integration/ChatMiscIntegrationTest.php | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tests/Integration/ChatMiscIntegrationTest.php b/tests/Integration/ChatMiscIntegrationTest.php index d31a00e..cb8861f 100644 --- a/tests/Integration/ChatMiscIntegrationTest.php +++ b/tests/Integration/ChatMiscIntegrationTest.php @@ -647,15 +647,16 @@ public function channelBatchUpdate(): void /** * @test */ - public function setRetentionPolicy(): string + public function getRetentionPolicy(): string { + $policyName = 'old-messages'; + + // Ensure a policy exists before querying try { - $resp = $this->client->setRetentionPolicy(new GeneratedModels\SetRetentionPolicyRequest( - policy: 'old-messages', + $this->client->setRetentionPolicy(new GeneratedModels\SetRetentionPolicyRequest( + policy: $policyName, maxAgeHours: 720, )); - $this->assertResponseSuccess($resp, 'set retention policy'); - self::assertNotNull($resp->getData()->policy, 'Policy 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'); @@ -664,15 +665,6 @@ public function setRetentionPolicy(): string throw $e; } - return 'old-messages'; - } - - /** - * @test - * @depends setRetentionPolicy - */ - public function getRetentionPolicy(string $policyName): string - { try { $resp = $this->client->getRetentionPolicy(); $this->assertResponseSuccess($resp, 'get retention policy'); From 49b34e897adbbd23c52fe67bac00b34214ae9da3 Mon Sep 17 00:00:00 2001 From: Faiz Shaikh Date: Mon, 23 Mar 2026 17:29:43 +0100 Subject: [PATCH 3/4] test: remove delete retention policy test Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/Integration/ChatMiscIntegrationTest.php | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/tests/Integration/ChatMiscIntegrationTest.php b/tests/Integration/ChatMiscIntegrationTest.php index cb8861f..527cb0a 100644 --- a/tests/Integration/ChatMiscIntegrationTest.php +++ b/tests/Integration/ChatMiscIntegrationTest.php @@ -685,7 +685,7 @@ public function getRetentionPolicy(): string * @test * @depends getRetentionPolicy */ - public function getRetentionPolicyRuns(string $policyName): string + public function getRetentionPolicyRuns(string $policyName): void { try { $resp = $this->client->getRetentionPolicyRuns(limit: 10, offset: 0); @@ -699,27 +699,6 @@ public function getRetentionPolicyRuns(string $policyName): string throw $e; } - return $policyName; - } - - /** - * @test - * @depends getRetentionPolicyRuns - */ - public function deleteRetentionPolicy(string $policyName): void - { - try { - $resp = $this->client->deleteRetentionPolicy(new GeneratedModels\DeleteRetentionPolicyRequest( - policy: $policyName, - )); - $this->assertResponseSuccess($resp, 'delete retention 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; - } } protected static function sharedUserCount(): int From 68ce879c2423c0d6bac6caaca0fd52638c0c80d1 Mon Sep 17 00:00:00 2001 From: Faiz Shaikh Date: Mon, 23 Mar 2026 17:30:44 +0100 Subject: [PATCH 4/4] test: remove delete retention policy tests Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/Integration/ChatMiscIntegrationTest.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/Integration/ChatMiscIntegrationTest.php b/tests/Integration/ChatMiscIntegrationTest.php index 527cb0a..55ff34f 100644 --- a/tests/Integration/ChatMiscIntegrationTest.php +++ b/tests/Integration/ChatMiscIntegrationTest.php @@ -647,7 +647,7 @@ public function channelBatchUpdate(): void /** * @test */ - public function getRetentionPolicy(): string + public function getRetentionPolicy(): void { $policyName = 'old-messages'; @@ -676,16 +676,21 @@ public function getRetentionPolicy(): string } throw $e; + } finally { + // Clean up the policy we created + try { + $this->client->deleteRetentionPolicy(new GeneratedModels\DeleteRetentionPolicyRequest( + policy: $policyName, + )); + } catch (\Exception $ignore) { + } } - - return $policyName; } /** * @test - * @depends getRetentionPolicy */ - public function getRetentionPolicyRuns(string $policyName): void + public function getRetentionPolicyRuns(): void { try { $resp = $this->client->getRetentionPolicyRuns(limit: 10, offset: 0); @@ -698,7 +703,6 @@ public function getRetentionPolicyRuns(string $policyName): void throw $e; } - } protected static function sharedUserCount(): int