public function PaymentStatusFormTest::testValidateForm in Payment 8.2
@covers ::validateForm @covers ::getPluginSelector
File
- tests/
src/ Unit/ Entity/ Payment/ PaymentStatusFormTest.php, line 227
Class
- PaymentStatusFormTest
- @coversDefaultClass \Drupal\payment\Entity\Payment\PaymentStatusForm
Namespace
Drupal\Tests\payment\Unit\Entity\PaymentCode
public function testValidateForm() {
$form = [
'payment_status' => [
'foo' => $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')
->willReturn($this->pluginSelector);
$this->pluginSelector
->expects($this
->atLeastOnce())
->method('validateSelectorForm')
->with($form['payment_status'], $form_state);
$payment_status_manager = $this
->prophesize(PaymentStatusManagerInterface::class);
$this->paymentStatusPluginType
->getPluginManager()
->willReturn($payment_status_manager
->reveal());
$this->sut
->validateForm($form, $form_state);
}