You are here

protected function ApidocEntityRevisionsAccessTest::setUp in Apigee API Catalog 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/ApidocEntityRevisionsAccessTest.php, line 87

Class

ApidocEntityRevisionsAccessTest
Tests the ApiDoc entity access permissions.

Namespace

Drupal\Tests\apigee_api_catalog\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('apidoc');
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this->entityTypeManager = $this->container
    ->get('entity_type.manager');
  $this->entityTypeStorage = $this->entityTypeManager
    ->getStorage('apidoc');

  // Create a published apidoc.
  $apidoc = $this->entityTypeStorage
    ->create([
    'name' => 'API 1',
    'description' => 'Test API v1',
    'spec' => NULL,
    'api_product' => NULL,
    'status' => 1,
  ]);
  $apidoc
    ->save();
  $this->apidocV1Id = $apidoc
    ->getRevisionId();

  // Create a new revision.
  $apidoc
    ->setDescription('Test API v2');
  $apidoc
    ->setRevisionLogMessage('v2');
  $apidoc
    ->setNewRevision();
  $apidoc
    ->save();
  $this->apidocV2Id = $apidoc
    ->getRevisionId();
  $this->apidoc = $apidoc;

  // Discard user 1, we will not need it because it bypasses access control.
  $this
    ->createUser();
}