You are here

public function PaymentFormTest::testCreate in Payment 8.2

Same name in this branch
  1. 8.2 modules/payment_form/tests/src/Unit/Plugin/Payment/Type/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Plugin\Payment\Type\PaymentFormTest::testCreate()
  2. 8.2 modules/payment_form/tests/src/Unit/Plugin/Field/FieldFormatter/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Plugin\Field\FieldFormatter\PaymentFormTest::testCreate()
  3. 8.2 modules/payment_form/tests/src/Unit/Plugin/Field/FieldWidget/PaymentFormTest.php \Drupal\Tests\payment_form\Unit\Plugin\Field\FieldWidget\PaymentFormTest::testCreate()

@covers ::create @covers ::__construct

File

modules/payment_form/tests/src/Unit/Plugin/Field/FieldFormatter/PaymentFormTest.php, line 119

Class

PaymentFormTest
@coversDefaultClass \Drupal\payment_form\Plugin\Field\FieldFormatter\PaymentForm

Namespace

Drupal\Tests\payment_form\Unit\Plugin\Field\FieldFormatter

Code

public function testCreate() {
  $entity_type_manager = $this
    ->createMock(EntityTypeManagerInterface::class);
  $entity_type_manager
    ->expects($this
    ->atLeastOnce())
    ->method('getStorage')
    ->with('payment')
    ->willReturn($this->paymentStorage);
  $container = $this
    ->createMock(ContainerInterface::class);
  $map = [
    [
      'entity.form_builder',
      ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
      $this->entityFormBuilder,
    ],
    [
      'entity_type.manager',
      ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
      $entity_type_manager,
    ],
    [
      'plugin.manager.payment.line_item',
      ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
      $this->paymentLineItemManager,
    ],
    [
      'request_stack',
      ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
      $this->requestStack,
    ],
  ];
  $container
    ->expects($this
    ->atLeastOnce())
    ->method('get')
    ->willReturnMap($map);
  $plugin_configuration = [
    'field_definition' => $this->fieldDefinition,
    'label' => $this
      ->randomMachineName(),
    'settings' => [],
    'third_party_settings' => [],
    'view_mode' => $this
      ->randomMachineName(),
  ];
  $this->sut = PaymentForm::create($container, $plugin_configuration, $this
    ->randomMachineName(), []);
}