public function CommerceMigrateTestTrait::assertOrderItem in Commerce Migrate 8.2
Same name and namespace in other branches
- 3.1.x tests/src/Kernel/CommerceMigrateTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateTestTrait::assertOrderItem()
- 3.0.x tests/src/Kernel/CommerceMigrateTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateTestTrait::assertOrderItem()
Asserts an order item.
Parameters
array $order_item: An array of order item information.
- order_item_id: The order item id.
- purchased_entity_id: The id of the purchased entity.
- created: The time the order item was created.
- changed: The time the order item was changed.
- quantity: The order quantity.
- title: The title of the item.
- unit_price: The unit price of the item.
- unit_price_currency_code: The unit price currency code.
- total_price: The total price of this item.
- total_price_currency_code: The total price currency code.
- uses_legacy_adjustments: Set if the line item uses legacy adjustment
calculation.
- adjustments: An array of adjustments to this order item.
3 calls to CommerceMigrateTestTrait::assertOrderItem()
- OrderItemTest::testOrderItem in modules/
ubercart/ tests/ src/ Kernel/ Migrate/ uc7/ OrderItemTest.php - Test order item migration.
- OrderItemTest::testOrderItem in modules/
commerce/ tests/ src/ Kernel/ Migrate/ commerce1/ OrderItemTest.php - Test line item migration from Drupal 7 to 8.
- OrderItemTest::testOrderItem in modules/
ubercart/ tests/ src/ Kernel/ Migrate/ uc6/ OrderItemTest.php - Test order item migration.
File
- tests/
src/ Kernel/ CommerceMigrateTestTrait.php, line 309
Class
- CommerceMigrateTestTrait
- Helper function to test migrations.
Namespace
Drupal\Tests\commerce_migrate\KernelCode
public function assertOrderItem(array $order_item) {
$actual = OrderItem::load($order_item['id']);
$this
->assertInstanceOf(OrderItem::class, $actual);
$this
->assertSame($order_item['created'], $actual
->getCreatedTime());
$this
->assertSame($order_item['changed'], $actual
->getChangedTime());
$formatted_number = $this
->formatNumber($order_item['quantity'], $actual
->getQuantity(), '%01.2f');
$this
->assertSame($formatted_number['expected'], $formatted_number['actual']);
$this
->assertEquals($order_item['title'], $actual
->getTitle());
$formatted_number = $this
->formatNumber($order_item['unit_price'], $actual
->getUnitPrice()
->getNumber());
$this
->assertSame($formatted_number['expected'], $formatted_number['actual']);
$this
->assertEquals($order_item['unit_price_currency_code'], $actual
->getUnitPrice()
->getCurrencyCode());
$formatted_number = $this
->formatNumber($order_item['total_price'], $actual
->getTotalPrice()
->getNumber());
$this
->assertSame($formatted_number['expected'], $formatted_number['actual']);
$this
->assertEquals($order_item['total_price_currency_code'], $actual
->getTotalPrice()
->getCurrencyCode());
$this
->assertEquals($order_item['purchased_entity_id'], $actual
->getPurchasedEntityId());
$this
->assertEquals($order_item['order_id'], $actual
->getOrderId());
$this
->assertSame($order_item['uses_legacy_adjustments'], $actual
->usesLegacyAdjustments());
$this
->assertAdjustments($order_item['adjustments'], $actual
->getAdjustments());
}