public function PaymentFormTest::testActionsWithAvailablePlugins in Payment 8.2
@covers ::actions @covers ::getPaymentMethodManager
File
- modules/
payment_form/ tests/ src/ Unit/ Entity/ Payment/ PaymentFormTest.php, line 331
Class
- PaymentFormTest
- @coversDefaultClass \Drupal\payment_form\Entity\Payment\PaymentForm
Namespace
Drupal\Tests\payment_form\Unit\Entity\PaymentCode
public function testActionsWithAvailablePlugins() {
$form = [];
$form_state = new FormState();
$form_state
->set('plugin_selector', $this->pluginSelector);
$plugin_id_a = reset($this->configFactoryConfiguration['payment_form.payment_type']['allowed_plugin_ids']);
$plugin_id_b = $this
->randomMachineName();
$plugin_a = $this
->createMock(PaymentMethodInterface::class);
$plugin_a
->expects($this
->atLeastOnce())
->method('executePaymentAccess')
->with($this->currentUser)
->willReturn(AccessResult::allowed());
$plugin_definitions = [
$plugin_id_a => [
'id' => $plugin_id_a,
],
$plugin_id_b => [
'id' => $plugin_id_b,
],
];
$this->paymentMethodManager
->expects($this
->atLeastOnce())
->method('getDefinitions')
->willReturn($plugin_definitions);
$this->paymentMethodManager
->expects($this
->once())
->method('createInstance')
->with($plugin_id_a)
->willReturn($plugin_a);
$this->configFactory = $this
->getConfigFactoryStub($this->configFactoryConfiguration);
$method = new \ReflectionMethod($this->sut, 'actions');
$method
->setAccessible(TRUE);
$actions = $method
->invokeArgs($this->sut, [
$form,
$form_state,
]);
$this
->assertFalse($actions['submit']['#disabled']);
}