You are here

public function AdjustmentTest::testMismatchedSourceIds in Commerce Core 8.2

@covers ::add

File

modules/order/tests/src/Kernel/AdjustmentTest.php, line 232

Class

AdjustmentTest
@coversDefaultClass \Drupal\commerce_order\Adjustment @group commerce

Namespace

Drupal\Tests\commerce_order\Kernel

Code

public function testMismatchedSourceIds() {
  $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' => 'custom',
    'amount' => new Price('3.00', 'USD'),
    'label' => '10% off',
    'percentage' => '0.1',
    'source_id' => '2',
    'included' => TRUE,
    'locked' => TRUE,
  ]);
  $this
    ->expectException(\InvalidArgumentException::class);
  $this
    ->expectExceptionMessage('Adjustment source ID "2" does not match "1".');
  $first_adjustment
    ->add($second_adjustment);
}