You are here

public function CommercePriceTest::providerTestCommercePrice in Commerce Migrate 8.2

Same name in this branch
  1. 8.2 modules/magento/tests/src/Unit/Plugin/migrate/process/CommercePriceTest.php \Drupal\Tests\commerce_migrate_magento\Unit\Plugin\migrate\process\CommercePriceTest::providerTestCommercePrice()
  2. 8.2 modules/csv_example/tests/src/Unit/Plugin/migrate/process/CommercePriceTest.php \Drupal\Tests\commerce_migrate_csv_example\Unit\Plugin\migrate\process\CommercePriceTest::providerTestCommercePrice()
  3. 8.2 modules/shopify/tests/src/Unit/Plugin/migrate/process/CommercePriceTest.php \Drupal\Tests\commerce_migrate_shopify\Unit\Plugin\migrate\process\CommercePriceTest::providerTestCommercePrice()
  4. 8.2 modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/CommercePriceTest.php \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\CommercePriceTest::providerTestCommercePrice()
Same name and namespace in other branches
  1. 3.1.x modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/CommercePriceTest.php \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\CommercePriceTest::providerTestCommercePrice()
  2. 3.0.x modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/CommercePriceTest.php \Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1\CommercePriceTest::providerTestCommercePrice()

Data provider for testSubstr().

File

modules/commerce/tests/src/Unit/Plugin/migrate/process/commerce1/CommercePriceTest.php, line 33

Class

CommercePriceTest
Tests the Commerce Price plugin.

Namespace

Drupal\Tests\commerce_migrate_commerce\Unit\Plugin\migrate\process\commerce1

Code

public function providerTestCommercePrice() {

  // Test the input amount > 0 with different fraction digits.
  $tests[0]['value'] = [
    'amount' => '234',
    'currency_code' => 'NZD',
    'fraction_digits' => 0,
  ];
  $tests[0]['expected'] = [
    'number' => '234',
    'currency_code' => 'NZD',
  ];
  $tests[1]['value'] = $tests[0]['value'];
  $tests[1]['value']['fraction_digits'] = 1;
  $tests[1]['expected'] = [
    'number' => '23.4',
    'currency_code' => 'NZD',
  ];

  // Tests with fractional input.
  $tests[2]['value'] = [
    'amount' => '234.56',
    'currency_code' => 'NZD',
    'fraction_digits' => 0,
  ];
  $tests[2]['expected'] = [
    'number' => '234.56',
    'currency_code' => 'NZD',
  ];
  $tests[3]['value'] = [
    'amount' => '234.56',
    'currency_code' => 'NZD',
    'fraction_digits' => 3,
  ];
  $tests[3]['expected'] = [
    'number' => '0.23456',
    'currency_code' => 'NZD',
  ];
  return $tests;
}