protected function ProductAddonTest::setUp in Commerce Product Add-on 8
Overrides CartBrowserTestBase::setUp
File
- tests/
src/ Functional/ ProductAddonTest.php, line 46
Class
- ProductAddonTest
- Functional test of the formatter and form.
Namespace
Drupal\Tests\commerce_pado\FunctionalCode
protected function setUp() {
parent::setUp();
$product = $this->variation
->getProduct();
$this
->createEntityReferenceField($product
->getEntityTypeId(), $product
->bundle(), 'pado', 'Addons', $product
->getEntityTypeId(), 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
// Use the add-on formatter.
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
$view_display = commerce_get_entity_display($product
->getEntityTypeId(), $product
->bundle(), 'view');
$view_display
->setComponent('variations', [
'type' => 'commerce_pado_add_to_cart',
'label' => 'hidden',
'settings' => [
'add_on_field' => 'pado',
'multiple' => 0,
],
]);
$view_display
->save();
$this->orderStorage = $this->container
->get('entity_type.manager')
->getStorage('commerce_order');
$this->productStorage = $this->container
->get('entity_type.manager')
->getStorage('commerce_product');
}