You are here

public function ExchangeRateProviderManagerTest::testGetDefinitions in Currency 8.3

@covers ::getDefinitions

File

tests/src/Unit/Plugin/Currency/ExchangeRateProvider/ExchangeRateProviderManagerTest.php, line 93

Class

ExchangeRateProviderManagerTest
@coversDefaultClass \Drupal\currency\Plugin\Currency\ExchangeRateProvider\ExchangeRateProviderManager

Namespace

Drupal\Tests\currency\Unit\Plugin\Currency\ExchangeRateProvider

Code

public function testGetDefinitions() {
  $plugin_id_a = $this
    ->randomMachineName();
  $plugin_id_b = $this
    ->randomMachineName();
  $plugin_id_c = $this
    ->randomMachineName();
  $discovery_definitions = [
    $plugin_id_a => [
      'label' => $this
        ->randomMachineName(),
    ],
    $plugin_id_b => [
      'label' => $this
        ->randomMachineName(),
      'description' => $this
        ->randomMachineName(),
    ],
    $plugin_id_c => [
      'label' => $this
        ->randomMachineName(),
    ],
  ];
  $this->discovery
    ->expects($this
    ->atLeastOnce())
    ->method('getDefinitions')
    ->willReturn($discovery_definitions);
  $definitions = $this->sut
    ->getDefinitions();
  foreach ([
    $plugin_id_a,
    $plugin_id_b,
    $plugin_id_c,
  ] as $plugin_id) {
    $this
      ->assertArrayHasKey('description', $definitions[$plugin_id]);
  }
}