protected function PaymentFormWebTest::setUp in Payment 8.2
{@inheritdoc
Overrides BrowserTestBase::setUp
File
- modules/
payment_form/ tests/ src/ Functional/ Plugin/ Field/ FieldFormatter/ PaymentFormWebTest.php, line 61
Class
- PaymentFormWebTest
- \Drupal\payment\Plugin\Field\FieldFormatter\PaymentForm web test.
Namespace
Drupal\Tests\payment_form\Functional\Plugin\Field\FieldFormatterCode
protected function setUp() : void {
parent::setUp();
$this->paymentStorage = \Drupal::entityTypeManager()
->getStorage('payment');
/** @var \Drupal\currency\ConfigImporterInterface $config_importer */
$config_importer = \Drupal::service('currency.config_importer');
$config_importer
->importCurrency('EUR');
// Create the field and field instance.
$field_name = strtolower($this
->randomMachineName());
FieldStorageConfig::create([
'cardinality' => FieldStorageConfigInterface::CARDINALITY_UNLIMITED,
'entity_type' => 'user',
'field_name' => $field_name,
'type' => 'payment_form',
])
->save();
FieldConfig::create([
'bundle' => 'user',
'entity_type' => 'user',
'field_name' => $field_name,
'settings' => [
'currency_code' => 'EUR',
],
])
->save();
\Drupal::service('entity_display.repository')
->getViewDisplay('user', 'user', 'default')
->setComponent($field_name, [
'type' => 'payment_form',
])
->save();
// Create an entity.
$this->user = User::create([
'name' => $this
->randomString(),
'status' => TRUE,
]);
foreach (Generate::createPaymentLineItems() as $line_item) {
$this->user
->get($field_name)
->appendItem([
'plugin_id' => $line_item
->getPluginId(),
'plugin_configuration' => $line_item
->getConfiguration(),
]);
}
$this->user
->save();
// Create a payment method.
$this->paymentMethod = Generate::createPaymentMethodConfiguration(2, 'payment_basic');
$this->paymentMethod
->setPluginConfiguration([
'execute_status_id' => $this->executeStatusPluginId,
]);
$this->paymentMethod
->save();
}