public function PaymentFormTest::testValidateForm in Payment 8.2
@covers ::validateForm @covers ::getPluginSelector @covers ::getPaymentMethodManager
File
- modules/
payment_form/ tests/ src/ Unit/ Entity/ Payment/ PaymentFormTest.php, line 230
Class
- PaymentFormTest
- @coversDefaultClass \Drupal\payment_form\Entity\Payment\PaymentForm
Namespace
Drupal\Tests\payment_form\Unit\Entity\PaymentCode
public function testValidateForm() {
$form = [
'payment_method' => [
'#type' => $this
->randomMachineName(),
],
];
$form_state = new FormState();
$form_display = $this
->prophesize(EntityFormDisplayInterface::class);
$form_display
->extractFormValues(Argument::any(), Argument::any(), Argument::any())
->shouldBeCalled();
$form_display
->flagWidgetsErrorsFromViolations(Argument::any(), Argument::any(), Argument::any())
->shouldBeCalled();
$form_display
->getComponents()
->willReturn([]);
$form_state
->set('form_display', $form_display
->reveal());
$entity_type = new EntityType([
'id' => 'payment',
]);
$this->payment
->expects($this
->any())
->method('getEntityType')
->willReturn($entity_type);
$this->payment
->expects($this
->any())
->method('validate')
->willReturn(new EntityConstraintViolationList($this->payment));
$this->payment
->expects($this
->any())
->method('getFieldDefinitions')
->willReturn([]);
$this->pluginSelectorManager
->expects($this
->once())
->method('createInstance')
->with($this->configFactoryConfiguration['payment_form.payment_type']['plugin_selector_id'])
->willReturn($this->pluginSelector);
$this->pluginSelector
->expects($this
->once())
->method('validateSelectorForm')
->with($form['payment_method'], $form_state);
$this->sut
->validateForm($form, $form_state);
}