You are here

public function PaymentAwarePluginFilteredPluginManagerTest::testCreateInstance in Payment 8.2

@covers ::createInstance

File

tests/src/Unit/Plugin/Payment/PaymentAwarePluginFilteredPluginManagerTest.php, line 51

Class

PaymentAwarePluginFilteredPluginManagerTest
@coversDefaultClass \Drupal\payment\Plugin\Payment\PaymentAwarePluginManagerDecorator

Namespace

Drupal\Tests\payment\Unit\Plugin\Payment

Code

public function testCreateInstance() {
  $plugin_id_a = $this
    ->randomMachineName();
  $plugin_a = $this
    ->createMock(PluginInspectionInterface::class);
  $plugin_id_b = $this
    ->randomMachineName();
  $plugin_b = $this
    ->createMock(PaymentAwarePluginFilteredPluginManagerUnitTestPaymentAwarePlugin::class);
  $plugin_b
    ->expects($this
    ->atLeastOnce())
    ->method('setPayment')
    ->with($this->payment);
  $map = [
    [
      $plugin_id_a,
      [],
      $plugin_a,
    ],
    [
      $plugin_id_b,
      [],
      $plugin_b,
    ],
  ];
  $this->pluginManager
    ->expects($this
    ->atLeast(count($map)))
    ->method('createInstance')
    ->willReturnMap($map);
  $this
    ->assertSame($plugin_a, $this->sut
    ->createInstance($plugin_id_a));
  $this
    ->assertSame($plugin_b, $this->sut
    ->createInstance($plugin_id_b));
}