You are here

public function CommerceMigrateTestTrait::assertAdjustments in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/CommerceMigrateTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateTestTrait::assertAdjustments()
  2. 3.0.x tests/src/Kernel/CommerceMigrateTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateTestTrait::assertAdjustments()

Assert multiple adjustments.

Parameters

\Drupal\commerce_order\Adjustment[] $expected_adjustments: An array of expected adjustments.

\Drupal\commerce_order\Adjustment[] $actual_adjustments: An array of actual adjustments.

2 calls to CommerceMigrateTestTrait::assertAdjustments()
CommerceMigrateTestTrait::assertOrder in tests/src/Kernel/CommerceMigrateTestTrait.php
Asserts an order entity.
CommerceMigrateTestTrait::assertOrderItem in tests/src/Kernel/CommerceMigrateTestTrait.php
Asserts an order item.

File

tests/src/Kernel/CommerceMigrateTestTrait.php, line 150

Class

CommerceMigrateTestTrait
Helper function to test migrations.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

public function assertAdjustments(array $expected_adjustments, array $actual_adjustments) {
  $this
    ->assertSame(count($expected_adjustments), count($actual_adjustments));
  $i = 0;
  foreach ($expected_adjustments as $expected) {
    foreach ($actual_adjustments as $actual) {
      if ($expected
        ->getLabel() === $actual
        ->getLabel() && $expected
        ->getType() === $actual
        ->getType()) {
        $this
          ->assertAdjustment($expected, $actual);
        $i++;
        break;
      }
    }
  }

  // Assert that every adjustment was tested.
  $this
    ->assertSame(count($actual_adjustments), $i);
}