Skip to content

Commit 13bf6b5

Browse files
committed
feat(test): skip deprecated API tests for Synonyms and Analytics
1 parent 9f3feb0 commit 13bf6b5

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

tests/Feature/AnalyticsEventsTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Feature;
44

55
use Tests\TestCase;
6+
use Exception;
67

78
class AnalyticsEventsTest extends TestCase
89
{
@@ -11,6 +12,11 @@ class AnalyticsEventsTest extends TestCase
1112
protected function setUp(): void
1213
{
1314
parent::setUp();
15+
16+
if ($this->isV30OrAbove()) {
17+
$this->markTestSkipped('Analytics is deprecated in Typesense v30+');
18+
}
19+
1420
$this->client()->collections->create([
1521
"name" => "products",
1622
"fields" => [
@@ -52,7 +58,13 @@ protected function setUp(): void
5258
protected function tearDown(): void
5359
{
5460
parent::tearDown();
55-
$this->client()->analytics->rules()->{'product_queries_aggregation'}->delete();
61+
62+
if (!$this->isV30OrAbove()) {
63+
try {
64+
$this->client()->analytics->rules()->{'product_queries_aggregation'}->delete();
65+
} catch (Exception $e) {
66+
}
67+
}
5668
}
5769

5870
public function testCanCreateAnEvent(): void

tests/Feature/AnalyticsRulesTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Tests\TestCase;
66
use Typesense\Exceptions\ObjectNotFound;
7+
use Exception;
78

89
class AnalyticsRulesTest extends TestCase
910
{
@@ -26,14 +27,26 @@ class AnalyticsRulesTest extends TestCase
2627
protected function setUp(): void
2728
{
2829
parent::setUp();
30+
31+
if ($this->isV30OrAbove()) {
32+
$this->markTestSkipped('Analytics is deprecated in Typesense v30+');
33+
}
34+
2935
$this->ruleUpsertResponse = $this->client()->analytics->rules()->upsert($this->ruleName, $this->ruleConfiguration);
3036
}
3137

3238
protected function tearDown(): void
3339
{
34-
$rules = $this->client()->analytics->rules()->retrieve();
35-
foreach ($rules['rules'] as $rule) {
36-
$this->client()->analytics->rules()->{$rule['name']}->delete();
40+
if (!$this->isV30OrAbove()) {
41+
try {
42+
$rules = $this->client()->analytics->rules()->retrieve();
43+
if (is_array($rules) && isset($rules['rules'])) {
44+
foreach ($rules['rules'] as $rule) {
45+
$this->client()->analytics->rules()->{$rule['name']}->delete();
46+
}
47+
}
48+
} catch (Exception $e) {
49+
}
3750
}
3851
}
3952

tests/Feature/SynonymsTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ class SynonymsTest extends TestCase
1717
protected function setUp(): void
1818
{
1919
parent::setUp();
20+
21+
if ($this->isV30OrAbove()) {
22+
$this->markTestSkipped('Synonyms is deprecated in Typesense v30+, use SynonymSets instead');
23+
}
24+
2025
$this->setUpCollection('books');
2126

2227
$this->synonyms = $this->client()->collections['books']->synonyms;

0 commit comments

Comments
 (0)