protected function CheckoutPaneTest::setUp in Commerce Checkout Order Fields 8
Overrides OrderKernelTestBase::setUp
File
- tests/
src/ Kernel/ CheckoutPaneTest.php, line 36
Class
- CheckoutPaneTest
- Tests the checkout pane.
Namespace
Drupal\Tests\commerce_checkout_order_fields\KernelCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('profile');
$this
->installEntitySchema('commerce_order');
$this
->installEntitySchema('commerce_order_item');
$this
->installEntitySchema('commerce_product');
$this
->installEntitySchema('commerce_product_variation');
$this
->installConfig('commerce_order');
$this
->installConfig('commerce_product');
$this
->installConfig('commerce_checkout');
$this
->installConfig('commerce_checkout_order_fields');
$checkout_pane_manager = $this->container
->get('plugin.manager.commerce_checkout_pane');
$checkout_pane_manager
->clearCachedDefinitions();
$field_storage = FieldStorageConfig::create([
'field_name' => 'test_string_field',
'entity_type' => 'commerce_order',
'type' => 'string',
]);
$field_storage
->save();
$instance = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'default',
'label' => 'Test String Field',
]);
$instance
->save();
$form_display = EntityFormDisplay::create([
'targetEntityType' => 'commerce_order',
'bundle' => 'default',
'mode' => 'checkout',
'status' => TRUE,
]);
$form_display
->removeComponent('adjustments');
$form_display
->removeComponent('billing_profile');
$form_display
->removeComponent('order_items');
$form_display
->setComponent('test_string_field', [
'type' => 'string_textfield',
'region' => 'content',
]);
$form_display
->save();
$view_mode = EntityViewMode::create([
'id' => 'commerce_order.checkout',
'targetEntityType' => 'commerce_order',
'status' => TRUE,
'enabled' => TRUE,
'label' => 'Checkout view mode',
]);
$view_mode
->save();
$view_display = EntityViewDisplay::create([
'targetEntityType' => 'commerce_order',
'bundle' => 'default',
'mode' => 'checkout',
'status' => TRUE,
]);
$view_display
->setComponent('test_string_field', [
'type' => 'string',
'label' => 'above',
'region' => 'content',
])
->save();
$view_display
->save();
}