You are here

public function AmountFormatterManagerTest::testGetDefaultPlugin in Currency 8.3

@covers ::getDefaultPlugin

File

tests/src/Unit/Plugin/Currency/AmountFormatter/AmountFormatterManagerTest.php, line 150

Class

AmountFormatterManagerTest
@coversDefaultClass \Drupal\currency\Plugin\Currency\AmountFormatter\AmountFormatterManager

Namespace

Drupal\Tests\currency\Unit\Plugin\Currency\AmountFormatter

Code

public function testGetDefaultPlugin() {
  $namespaces = new ArrayObject();
  $default_plugin_id = $this
    ->randomMachineName();
  $formatter = $this
    ->createMock(AmountFormatterInterface::class);

  /** @var \Drupal\currency\Plugin\Currency\AmountFormatter\AmountFormatterManager|\PHPUnit_Framework_MockObject_MockObject $currency_amount_formatter_manager */
  $currency_amount_formatter_manager = $this
    ->getMockBuilder(AmountFormatterManager::class)
    ->setConstructorArgs(array(
    $namespaces,
    $this->cache,
    $this->moduleHandler,
    $this->configFactory,
  ))
    ->setMethods(array(
    'getDefaultPluginId',
    'createInstance',
  ))
    ->getMock();
  $currency_amount_formatter_manager
    ->expects($this
    ->once())
    ->method('getDefaultPluginId')
    ->willReturn($default_plugin_id);
  $currency_amount_formatter_manager
    ->expects($this
    ->once())
    ->method('createInstance')
    ->with($default_plugin_id)
    ->willReturn($formatter);
  $this
    ->assertSame(spl_object_hash($formatter), spl_object_hash($currency_amount_formatter_manager
    ->getDefaultPlugin()));
}