You are here

public function PaymentTest::testPayment in Commerce Migrate 3.1.x

Same name in this branch
  1. 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc7/PaymentTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\PaymentTest::testPayment()
  2. 3.1.x modules/ubercart/tests/src/Kernel/Migrate/uc6/PaymentTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc6\PaymentTest::testPayment()
  3. 3.1.x modules/commerce/tests/src/Kernel/Migrate/commerce1/PaymentTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Migrate\commerce1\PaymentTest::testPayment()
Same name and namespace in other branches
  1. 8.2 modules/ubercart/tests/src/Kernel/Migrate/uc7/PaymentTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\PaymentTest::testPayment()
  2. 3.0.x modules/ubercart/tests/src/Kernel/Migrate/uc7/PaymentTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7\PaymentTest::testPayment()

Tests payment migration.

File

modules/ubercart/tests/src/Kernel/Migrate/uc7/PaymentTest.php, line 63

Class

PaymentTest
Tests payment migration.

Namespace

Drupal\Tests\commerce_migrate_ubercart\Kernel\Migrate\uc7

Code

public function testPayment() {
  $payment = [
    'id' => 1,
    'order_id' => '1',
    'type' => 'payment_manual',
    'payment_gateway' => 'cod',
    'payment_method' => NULL,
    'amount_number' => '50.000000',
    'amount_currency_code' => 'USD',
    'refunded_amount_number' => '50.000000',
    'refunded_amount_currency_code' => 'USD',
    'balance_number' => '0',
    'balance_currency_code' => 'USD',
    'label_value' => 'refunded',
    'label_rendered' => 'Refunded',
  ];
  $this
    ->assertPaymentEntity($payment);
  $payment = [
    'id' => 3,
    'order_id' => '1',
    'type' => 'payment_manual',
    'payment_gateway' => 'cod',
    'payment_method' => NULL,
    'amount_number' => '53.000000',
    'amount_currency_code' => 'USD',
    'refunded_amount_number' => '50.000000',
    'refunded_amount_currency_code' => 'USD',
    'balance_number' => '3',
    'balance_currency_code' => 'USD',
    'label_value' => 'partially_refunded',
    'label_rendered' => 'Partially refunded',
  ];
  $this
    ->assertPaymentEntity($payment);
  $payment = [
    'id' => 5,
    'order_id' => '2',
    'type' => 'payment_manual',
    'payment_gateway' => 'cod',
    'payment_method' => NULL,
    'amount_number' => '400.000000',
    'amount_currency_code' => 'USD',
    'refunded_amount_number' => '0.000000',
    'refunded_amount_currency_code' => 'USD',
    'balance_number' => '400',
    'balance_currency_code' => 'USD',
    'label_value' => 'new',
    'label_rendered' => 'New',
  ];
  $this
    ->assertPaymentEntity($payment);
  $payment = [
    'id' => 6,
    'order_id' => '2',
    'type' => 'payment_manual',
    'payment_gateway' => 'cod',
    'payment_method' => NULL,
    'amount_number' => '40.400000',
    'amount_currency_code' => 'USD',
    'refunded_amount_number' => '0.000000',
    'refunded_amount_currency_code' => 'USD',
    'balance_number' => '40.4',
    'balance_currency_code' => 'USD',
    'label_value' => 'new',
    'label_rendered' => 'New',
  ];
  $this
    ->assertPaymentEntity($payment);

  /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
  $migration = $this
    ->getMigration('uc7_payment');

  // Check that we've reported the refund in excess of payments.
  $messages = [];
  foreach ($migration
    ->getIdMap()
    ->getMessages() as $message_row) {
    $messages[] = $message_row->message;
  }
  $this
    ->assertCount(1, $messages);
  $this
    ->assertSame('Refund exceeds payments for payment 7', $messages[0]);
}