/**
  * @covers ::execute
  */
 public function testExecute()
 {
     $plugin_id_a = $this->randomMachineName();
     $plugin_id_b = $this->randomMachineName();
     $definitions = [$plugin_id_a => ['active' => TRUE, 'class' => $this->getMockClass(PaymentMethodInterface::class), 'label' => $this->randomMachineName()], $plugin_id_b => ['active' => FALSE, 'class' => $this->getMockClass(PaymentMethodInterface::class), 'label' => $this->randomMachineName()]];
     $this->paymentMethodManager->expects($this->once())->method('getDefinitions')->willReturn($definitions);
     $build = $this->sut->execute();
     $this->assertInternalType('array', $build);
 }
 /**
  * @covers ::render
  */
 public function testRender()
 {
     $plugin_id = $this->randomMachineName();
     $plugin_label = $this->randomMachineName();
     $plugin_definition = ['label' => $plugin_label];
     $this->paymentMethodManager->expects($this->atLeastOnce())->method('getDefinition')->with($plugin_id)->willReturn($plugin_definition);
     $result_row = new ResultRow();
     $result_row->{$this->sut->field_alias} = $plugin_id;
     $this->assertSame($plugin_label, $this->sut->render($result_row));
 }
 /**
  * @covers ::invoke
  */
 public function testInvoke()
 {
     $payment_method = $this->getMock(PaymentMethodConfigurationInterface::class);
     $payment_method->expects($this->any())->method('getEntityTypeId')->willReturn('payment_method_configuration');
     $payment_status = $this->getMock(PaymentStatusInterface::class);
     $payment_status->expects($this->any())->method('getEntityTypeId')->willReturn('payment_status');
     $this->paymentMethodManager->expects($this->once())->method('clearCachedDefinitions');
     $this->paymentStatusManager->expects($this->once())->method('clearCachedDefinitions');
     $this->sut->invoke($payment_method);
     $this->sut->invoke($payment_status);
 }
 /**
  * @covers ::getValueOptions
  */
 public function testGetValueOptions()
 {
     $plugin_id_a = $this->randomMachineName();
     $plugin_label_a = $this->randomMachineName();
     $plugin_id_b = $this->randomMachineName();
     $plugin_label_b = $this->randomMachineName();
     $plugin_id_c = $this->randomMachineName();
     $plugin_label_c = $this->randomMachineName();
     $plugin_definitions = [$plugin_id_a => ['label' => $plugin_label_a], $plugin_id_b => ['label' => $plugin_label_b], $plugin_id_c => ['label' => $plugin_label_c]];
     $this->paymentMethodManager->expects($this->atLeastOnce())->method('getDefinitions')->willReturn($plugin_definitions);
     $expected_options = [$plugin_id_a => $plugin_label_a, $plugin_id_b => $plugin_label_b, $plugin_id_c => $plugin_label_c];
     $this->assertSame($expected_options, $this->sut->getValueOptions());
 }
 /**
  * @covers ::actions
  * @covers ::getPaymentMethodManager
  */
 public function testActionsWithoutAvailablePlugins()
 {
     $form = [];
     $form_state = new FormState();
     $form_state->set('plugin_selector', $this->pluginSelector);
     $this->paymentMethodManager->expects($this->atLeastOnce())->method('getDefinitions')->willReturn([]);
     $method = new \ReflectionMethod($this->sut, 'actions');
     $method->setAccessible(TRUE);
     $actions = $method->invokeArgs($this->sut, [$form, $form_state]);
     $this->assertTrue($actions['submit']['#disabled']);
 }
 /**
  * @covers ::buildForm
  * @covers ::getPluginSelector
  */
 public function testBuildForm()
 {
     $form = [];
     $form_state = new FormState();
     $map = [['payment_radios', [], $this->pluginSelector], [$this->configFactoryConfiguration['payment_form.payment_type']['plugin_selector_id'], [], $this->selectedPluginSelector]];
     $this->pluginSelectorManager->expects($this->atLeast(count($map)))->method('createInstance')->willReturnMap($map);
     $this->pluginSelector->expects($this->once())->method('buildSelectorForm')->with([], $form_state)->willReturn($this->pluginSelector);
     $this->paymentMethodManager->expects($this->atLeastOnce())->method('getDefinitions')->willReturn([]);
     $build = $this->sut->buildForm($form, $form_state);
     $this->assertInternalType('array', $build);
 }
 /**
  * @covers ::getOperationsProvider
  *
  * @expectedException \Drupal\Component\Plugin\Exception\PluginNotFoundException
  */
 public function testGetOperationsProviderWithNonExistentPlugin()
 {
     $this->paymentMethodManager->expects($this->atLeastOnce())->method('getDefinitions')->willReturn([]);
     $this->sut->getOperationsProvider($this->randomMachineName());
 }