public function PriceFormattersTest::testCalculatedFormatter in Commerce Core 8.2
Tests the calculated price formatter.
File
- modules/
price/ tests/ src/ Kernel/ PriceFormattersTest.php, line 137
Class
- PriceFormattersTest
- Tests price formatters provided by Price module.
Namespace
Drupal\Tests\commerce_price\KernelCode
public function testCalculatedFormatter() {
$this->productVariationDefaultDisplay
->setComponent('list_price', [
'type' => 'commerce_price_calculated',
'settings' => [],
]);
$this->productVariationDefaultDisplay
->setComponent('price', [
'type' => 'commerce_price_calculated',
'settings' => [],
]);
$this->productVariationDefaultDisplay
->save();
$build = $this->productVariationViewBuilder
->viewField($this->variation1->list_price, 'default');
$this
->render($build);
$this
->assertText('$14.00');
$build = $this->productVariationViewBuilder
->viewField($this->variation1->price, 'default');
$this
->render($build);
$this
->assertText('$12.00');
$this->productVariationDefaultDisplay
->setComponent('list_price', [
'type' => 'commerce_price_calculated',
'settings' => [
'currency_display' => 'code',
],
]);
$this->productVariationDefaultDisplay
->setComponent('price', [
'type' => 'commerce_price_calculated',
'settings' => [
'currency_display' => 'code',
],
]);
$this->productVariationDefaultDisplay
->save();
$build = $this->productVariationViewBuilder
->viewField($this->variation2->list_price, 'default');
$this
->render($build);
$this
->assertText('USD23.00');
$build = $this->productVariationViewBuilder
->viewField($this->variation2->price, 'default');
$this
->render($build);
$this
->assertText('USD21.00');
}