You are here

public function OrderProductNoCurrencyTest::providerSource in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 modules/ubercart/tests/src/Kernel/Plugin/migrate/source/OrderProductNoCurrencyTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source\OrderProductNoCurrencyTest::providerSource()
  2. 3.0.x modules/ubercart/tests/src/Kernel/Plugin/migrate/source/OrderProductNoCurrencyTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source\OrderProductNoCurrencyTest::providerSource()

The data provider.

Return value

array Array of data sets to test, each of which is a numerically indexed array with the following elements:

  • An array of source data, which can be optionally processed and set up by subclasses.
  • An array of expected result rows.
  • (optional) The number of result rows the plugin under test is expected to return. If this is not a numeric value, the plugin will not be counted.
  • (optional) Array of configuration options for the plugin under test.

Overrides OrderProductCurrencyTest::providerSource

See also

\Drupal\Tests\migrate\Kernel\MigrateSourceTestBase::testSource

File

modules/ubercart/tests/src/Kernel/Plugin/migrate/source/OrderProductNoCurrencyTest.php, line 21

Class

OrderProductNoCurrencyTest
Tests the Ubercart order product source plugin without currency data.

Namespace

Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source

Code

public function providerSource() {
  $tests = parent::providerSource();
  foreach ($tests as &$test) {

    // Remove currency from the source.
    foreach ($test['source_data']['uc_orders'] as &$data) {
      unset($data['currency']);
    }

    // Set the default currency on each order item and each adjustment.
    foreach ($test['expected_data'] as &$data) {
      $data['currency'] = 'USD';
      foreach ($data['adjustments'] as &$adjustment) {
        $adjustment['currency_code'] = 'USD';
      }
    }
  }
  return $tests;
}