protected function PriceFormattersTest::setUp in Commerce Core 8.2
Overrides CommerceKernelTestBase::setUp
File
- modules/
price/ tests/ src/ Kernel/ PriceFormattersTest.php, line 58
Class
- PriceFormattersTest
- Tests price formatters provided by Price module.
Namespace
Drupal\Tests\commerce_price\KernelCode
protected function setUp() : void {
parent::setUp();
$this
->installEntitySchema('commerce_product_attribute');
$this
->installEntitySchema('commerce_product_attribute_value');
$this
->installEntitySchema('commerce_product_variation');
$this
->installEntitySchema('commerce_product');
$this
->installConfig([
'commerce_product',
]);
$this->productVariationDefaultDisplay = commerce_get_entity_display('commerce_product_variation', 'default', 'view');
$this->productVariationViewBuilder = $this->container
->get('entity_type.manager')
->getViewBuilder('commerce_product_variation');
$variation = ProductVariation::create([
'type' => 'default',
'sku' => strtolower($this
->randomMachineName()),
'list_price' => new Price('14.00', 'USD'),
'price' => new Price('12.00', 'USD'),
]);
$variation
->save();
$this->variation1 = $variation;
$variation = ProductVariation::create([
'type' => 'default',
'sku' => 'TEST_' . strtolower($this
->randomMachineName()),
'list_price' => new Price('26.00', 'USD'),
'price' => new Price('24.00', 'USD'),
]);
$variation
->save();
$this->variation2 = $variation;
}