private function CommerceMigrateTestTrait::assertPaymentEntity in Commerce Migrate 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/CommerceMigrateTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateTestTrait::assertPaymentEntity()
- 3.1.x tests/src/Kernel/CommerceMigrateTestTrait.php \Drupal\Tests\commerce_migrate\Kernel\CommerceMigrateTestTrait::assertPaymentEntity()
Asserts a payment entity.
Parameters
array $payment: An array of payment information.
- The payment id.
- The order id for this payment.
- The payment type.
- The gateway id.
- The payment method.
- The payment amount.
- The payment currency code.
- The order balance.
- The order balance currency code.
- The refunded amount.
- The refunded amount currency code.
2 calls to CommerceMigrateTestTrait::assertPaymentEntity()
- PaymentTest::testPayment in modules/
ubercart/ tests/ src/ Kernel/ Migrate/ uc7/ PaymentTest.php - Tests payment migration.
- PaymentTest::testPayment in modules/
ubercart/ tests/ src/ Kernel/ Migrate/ uc6/ PaymentTest.php - Tests payment migration.
1 method overrides CommerceMigrateTestTrait::assertPaymentEntity()
- PaymentTest::assertPaymentEntity in modules/
commerce/ tests/ src/ Kernel/ Migrate/ commerce1/ PaymentTest.php - Asserts a payment entity.
File
- tests/
src/ Kernel/ CommerceMigrateTestTrait.php, line 368
Class
- CommerceMigrateTestTrait
- Helper function to test migrations.
Namespace
Drupal\Tests\commerce_migrate\KernelCode
private function assertPaymentEntity(array $payment) {
$payment_instance = Payment::load($payment['id']);
$this
->assertInstanceOf(Payment::class, $payment_instance);
$this
->assertSame($payment['order_id'], $payment_instance
->getOrderId());
$this
->assertSame($payment['type'], $payment_instance
->getType()
->getPluginId());
$this
->assertSame($payment['payment_gateway'], $payment_instance
->getPaymentGatewayId());
$this
->assertSame($payment['payment_method'], $payment_instance
->getPaymentMethodId());
$formatted_number = $this
->formatNumber($payment['amount_number'], $payment_instance
->getAmount()
->getNumber());
$this
->assertSame($formatted_number['expected'], $formatted_number['actual']);
$this
->assertSame($payment['amount_currency_code'], $payment_instance
->getAmount()
->getCurrencyCode());
$formatted_number = $this
->formatNumber($payment['balance_number'], $payment_instance
->getBalance()
->getNumber(), '%01.2f');
$this
->assertSame($formatted_number['expected'], $formatted_number['actual']);
$this
->assertSame($payment['balance_currency_code'], $payment_instance
->getBalance()
->getCurrencyCode());
$formatted_number = $this
->formatNumber($payment['refunded_amount_number'], $payment_instance
->getRefundedAmount()
->getNumber());
$this
->assertSame($formatted_number['expected'], $formatted_number['actual']);
$this
->assertSame($payment['refunded_amount_currency_code'], $payment_instance
->getRefundedAmount()
->getCurrencyCode());
$this
->assertSame($payment['label_value'], $payment_instance
->getState()->value);
$state_label = $payment_instance
->getState()
->getLabel();
$label = NULL;
if (is_string($state_label)) {
$label = $state_label;
}
elseif ($state_label instanceof TranslatableMarkup) {
$arguments = $state_label
->getArguments();
$label = isset($arguments['@label']) ? $arguments['@label'] : $state_label
->render();
}
$this
->assertSame($payment['label_rendered'], $label);
}