Skip to content

Commit 9f57454

Browse files
abnegateclaude
andcommitted
fix: use unique collection names in aggregation, relationship, and SharedTables tests
- Aggregation tests: add per-worker unique suffix to dp_agg_* and dp_grpby collection names to prevent cross-worker conflicts - OneToMany relationship tests: use uniqid() for teams/players/blogs/ posts/products/categories/authors/books/libraries collection names in all testPartialUpdate* and testOneToManyAndManyToOneDeleteRelationship - SharedTables: use unique name for multiTenantCol collection Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a55ef9d commit 9f57454

3 files changed

Lines changed: 158 additions & 143 deletions

File tree

tests/e2e/Adapter/Scopes/AggregationTests.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,26 @@
1414

1515
trait AggregationTests
1616
{
17+
private static array $createdProductCollections = [];
18+
private static string $aggWorkerSuffix = '';
19+
20+
private function getAggSuffix(): string
21+
{
22+
if (self::$aggWorkerSuffix === '') {
23+
self::$aggWorkerSuffix = '_' . substr(uniqid(), -6);
24+
}
25+
26+
return self::$aggWorkerSuffix;
27+
}
28+
1729
private function createProducts(Database $database, string $collection = 'agg_products'): void
1830
{
31+
if (isset(self::$createdProductCollections[$collection])) {
32+
return;
33+
}
34+
1935
if ($database->exists($database->getDatabase(), $collection)) {
36+
self::$createdProductCollections[$collection] = true;
2037
return;
2138
}
2239

@@ -1241,7 +1258,7 @@ public function testSingleAggregation(string $collSuffix, string $method, string
12411258
return;
12421259
}
12431260

1244-
$col = 'dp_agg_' . $collSuffix;
1261+
$col = 'dp_agg_' . $collSuffix . $this->getAggSuffix();
12451262
$this->createProducts($database, $col);
12461263

12471264
$aggQuery = match ($method) {
@@ -1288,7 +1305,7 @@ public function testGroupByCount(string $groupCol, array $filters, int $expected
12881305
return;
12891306
}
12901307

1291-
$col = 'dp_grpby';
1308+
$col = 'dp_grpby' . $this->getAggSuffix();
12921309
$this->createProducts($database, $col);
12931310

12941311
$queries = array_merge($filters, [

tests/e2e/Adapter/Scopes/CollectionTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ public function testSharedTablesMultiTenantCreateCollection(): void
921921
try {
922922
$tenant1 = $database->getAdapter()->getIdAttributeType() === ColumnType::Integer->value ? 10 : 'tenant_10';
923923
$tenant2 = $database->getAdapter()->getIdAttributeType() === ColumnType::Integer->value ? 20 : 'tenant_20';
924-
$colName = 'multiTenantCol';
924+
$colName = 'mt_' . uniqid();
925925

926926
$database->setTenant($tenant1);
927927

0 commit comments

Comments
 (0)