You are here

public function KeyEntityTest::testGetters in Key 8

Assert that key entity getters work.

File

tests/src/Unit/Entity/KeyEntityTest.php, line 65

Class

KeyEntityTest
@coversDefaultClass \Drupal\key\Entity\Key @group key

Namespace

Drupal\Tests\key\Unit\Entity

Code

public function testGetters() {

  // Create a key entity using Configuration key provider.
  $values = [
    'key_id' => $this
      ->getRandomGenerator()
      ->word(15),
    'key_provider' => 'config',
    'key_provider_settings' => $this->key_provider_settings,
  ];
  $key = new Key($values, 'key');
  $this
    ->assertEquals($values['key_provider'], $key
    ->getKeyProvider()
    ->getPluginId());
  $this
    ->assertEquals($values['key_provider_settings'], $key
    ->getKeyProvider()
    ->getConfiguration());
  $this
    ->assertEquals($values['key_provider_settings']['key_value'], $key
    ->getKeyProvider()
    ->getConfiguration()['key_value']);
}