You are here

protected function CacheInvalidationOnGroupChangeTest::setUp in Organic groups 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Entity/CacheInvalidationOnGroupChangeTest.php, line 42

Class

CacheInvalidationOnGroupChangeTest
Tests if group content listings are invalidated when group audience changes.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test');
  $this
    ->installEntitySchema('user');
  $this->cache = $this->container
    ->get('cache.default');

  // Add a OG group audience.
  Og::groupTypeManager()
    ->addGroup('entity_test', 'group');
  $settings = [
    'field_storage_config' => [
      'field_name' => OgGroupAudienceHelperInterface::DEFAULT_FIELD,
      'settings' => [
        'target_type' => 'entity_test',
      ],
    ],
    'field_config' => [
      'label' => $this
        ->randomString(),
      'settings' => [
        'handler_settings' => [
          'target_bundles' => [
            'group' => 'group',
          ],
        ],
      ],
    ],
  ];
  Og::createField(OgGroupAudienceHelperInterface::DEFAULT_FIELD, 'entity_test', 'group_content', $settings);
}