public function PriceEqualsTest::testPriceItemListEquals in Commerce Core 8.2
Tests that 12.00 and 12 are the same.
File
- modules/
price/ tests/ src/ Kernel/ PriceEqualsTest.php, line 52
Class
- PriceEqualsTest
- Tests that price item list `equals` works as expected.
Namespace
Drupal\Tests\commerce_price\KernelCode
public function testPriceItemListEquals() {
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $variation1 */
$variation1 = ProductVariation::create([
'type' => 'default',
'sku' => strtolower($this
->randomMachineName()),
'price' => new Price('12.00', 'USD'),
]);
$variation1
->save();
/** @var \Drupal\commerce_product\Entity\ProductVariationInterface $variation2 */
$variation2 = ProductVariation::create([
'type' => 'default',
'sku' => 'TEST_' . strtolower($this
->randomMachineName()),
'price' => new Price('12', 'USD'),
]);
$variation2
->save();
$this
->assertTrue($variation1
->get('price')
->equals($variation2
->get('price')));
}