You are here

protected function KeyTestTrait::createTestKey in Key 8

Make a key for testing operations that require a key.

4 calls to KeyTestTrait::createTestKey()
KeyAdminTest::testAdminUserRoutes in tests/src/Functional/KeyAdminTest.php
Tests key routes for an authorized user.
KeyNonAdminAccessTest::setUp in tests/src/Functional/KeyNonAdminAccessTest.php
KeyOverrideAdminTest::setUp in tests/src/Functional/KeyOverrideAdminTest.php
KeyRepositoryServiceTest::testKeyRepositoryService in tests/src/Functional/KeyRepositoryServiceTest.php
Test key provider methods.

File

tests/src/Functional/KeyTestTrait.php, line 44

Class

KeyTestTrait
Used for key access tests.

Namespace

Drupal\Tests\key\Functional

Code

protected function createTestKey($id, $type = NULL, $provider = NULL) {
  $keyArgs = [
    'id' => $id,
    'label' => 'Test key',
  ];
  if ($type != NULL) {
    $keyArgs['key_type'] = $type;
  }
  if ($provider != NULL) {
    $keyArgs['key_provider'] = $provider;
  }
  $this->testKey = Key::create($keyArgs);
  $this->testKey
    ->save();
  return $this->testKey;
}