Skip to content
Merged
Changes from 2 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
51 changes: 51 additions & 0 deletions tests/e2e/Adapter/Scopes/CollectionTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -1439,4 +1439,55 @@ public function testTransformations(): void

$this->assertTrue($result->isEmpty());
}

public function testSetGlobalCollection(): void
{
$db = static::getDatabase();

$collectionId = 'globalCollection';

// set collection as global
$db->setGlobalCollections([$collectionId]);
Comment thread
ArnabChatterjee20k marked this conversation as resolved.

// metadata collection should not contain tenant in the cache key
[$collectionKey, $documentKey, $hashKey] = $db->getCacheKeys(
Database::METADATA,
$collectionId,
[]
);

$this->assertNotEmpty($collectionKey);
$this->assertNotEmpty($documentKey);
$this->assertNotEmpty($hashKey);

if ($db->getSharedTables()) {
$this->assertStringNotContainsString((string)$db->getAdapter()->getTenant(), $collectionKey);
}

// non global collection should containt tenant in the cache key
$nonGlobalCollectionId = 'nonGlobalCollection';
[$collectionKeyRegular] = $db->getCacheKeys(
Database::METADATA,
$nonGlobalCollectionId
);
if ($db->getSharedTables()) {
$this->assertStringContainsString((string)$db->getAdapter()->getTenant(), $collectionKeyRegular);
}

// Non metadata collection should contain tenant in the cache key
[$collectionKey, $documentKey, $hashKey] = $db->getCacheKeys(
$collectionId,
ID::unique(),
[]
);

$this->assertNotEmpty($collectionKey);
$this->assertNotEmpty($documentKey);
$this->assertNotEmpty($hashKey);

if ($db->getSharedTables()) {
$this->assertStringContainsString((string)$db->getAdapter()->getTenant(), $collectionKey);
}

}
}