You are here

public function AdjustmentTransformerTest::testSorting in Commerce Core 8.2

Tests adjustment sorting.

@covers ::sortAdjustments

File

modules/order/tests/src/Kernel/AdjustmentTransformerTest.php, line 100

Class

AdjustmentTransformerTest
Tests the adjustment transformer.

Namespace

Drupal\Tests\commerce_order\Kernel

Code

public function testSorting() {
  $first_adjustment = new Adjustment([
    'type' => 'tax',
    'label' => 'VAT',
    'amount' => new Price('10', 'USD'),
    'percentage' => '0.1',
  ]);
  $second_adjustment = new Adjustment([
    'type' => 'promotion',
    'label' => '20% off',
    'amount' => new Price('20', 'USD'),
    'percentage' => '0.2',
  ]);
  $adjustments = $this->adjustmentTransformer
    ->sortAdjustments([
    $first_adjustment,
    $second_adjustment,
  ]);
  $this
    ->assertEquals([
    $second_adjustment,
    $first_adjustment,
  ], $adjustments);
}