public function GetBundleByBundleTest::testGetGroupContentBundleIdsByGroupBundleUsesCachedData in Organic groups 8
Tests that retrieval of group content bundle IDs uses cached data.
@covers ::getGroupContentBundleIdsByGroupBundle
File
- tests/
src/ Kernel/ Entity/ GetBundleByBundleTest.php, line 585
Class
- GetBundleByBundleTest
- Tests retrieving group content bundles by group bundles and vice versa.
Namespace
Drupal\Tests\og\Kernel\EntityCode
public function testGetGroupContentBundleIdsByGroupBundleUsesCachedData() {
// Initially no cached group relation data should exist.
$this
->assertNull($this
->getCachedGroupRelationMap());
// We do not yet have any group content types, so when we retrieve the group
// content bundle IDs we should get no result back, and the cache should
// remain empty.
$bundle_ids = $this->groupTypeManager
->getGroupContentBundleIdsByGroupBundle('node', 'group_0');
$this
->assertEquals([], $bundle_ids);
// The cached group relation data should now no longer be NULL but an empty
// array. NULL indicates the absence of cached data.
$this
->assertEquals([], $this
->getCachedGroupRelationMap());
// Reset the data, this should clear the cached data again.
$this->groupTypeManager
->reset();
$this
->assertNull($this
->getCachedGroupRelationMap());
// Inject some data in the cache, and check that the group type manager uses
// this cached data.
$relation_data = [
'node' => [
'group_0' => [
'group_content_entity_type_id' => [
'group_content_bundle_id',
],
],
],
];
$this
->cacheGroupRelationMap($relation_data);
$bundle_ids = $this->groupTypeManager
->getGroupContentBundleIdsByGroupBundle('node', 'group_0');
$this
->assertEquals($relation_data['node']['group_0'], $bundle_ids);
}