public function AdjustmentTest::testMismatchedTypes in Commerce Core 8.2
@covers ::add
File
- modules/
order/ tests/ src/ Kernel/ AdjustmentTest.php, line 204
Class
- AdjustmentTest
- @coversDefaultClass \Drupal\commerce_order\Adjustment @group commerce
Namespace
Drupal\Tests\commerce_order\KernelCode
public function testMismatchedTypes() {
$first_adjustment = new Adjustment([
'type' => 'custom',
'amount' => new Price('2.00', 'USD'),
'label' => '10% off',
'percentage' => '0.1',
'source_id' => '1',
'included' => TRUE,
'locked' => TRUE,
]);
$second_adjustment = new Adjustment([
'type' => 'promotion',
'amount' => new Price('3.00', 'USD'),
'label' => '10% off',
'percentage' => '0.1',
'source_id' => '1',
'included' => TRUE,
'locked' => TRUE,
]);
$this
->expectException(\InvalidArgumentException::class);
$this
->expectExceptionMessage('Adjustment type "promotion" does not match "custom".');
$first_adjustment
->add($second_adjustment);
}