You are here

public function BillingProfileTest::providerSource in Commerce Migrate 8.2

Same name and namespace in other branches
  1. 3.1.x modules/commerce/tests/src/Kernel/Plugin/migrate/source/commerce1/BillingProfileTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Plugin\migrate\source\commerce1\BillingProfileTest::providerSource()
  2. 3.0.x modules/commerce/tests/src/Kernel/Plugin/migrate/source/commerce1/BillingProfileTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Plugin\migrate\source\commerce1\BillingProfileTest::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 MigrateSourceTestBase::providerSource

See also

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

File

modules/commerce/tests/src/Kernel/Plugin/migrate/source/commerce1/BillingProfileTest.php, line 25

Class

BillingProfileTest
Tests the Commerce 1 billing profile source plugin.

Namespace

Drupal\Tests\commerce_migrate_commerce\Kernel\Plugin\migrate\source\commerce1

Code

public function providerSource() {
  $tests = [];
  $tests[0]['source_data']['commerce_customer_profile'] = [
    [
      'profile_id' => '1',
      'revision_id' => '1',
      'type' => 'billing',
      'uid' => '3',
      'status' => '1',
      'created' => '1493287440',
      'changed' => '1493287440',
      'data' => NULL,
    ],
    [
      'profile_id' => '2',
      'revision_id' => '2',
      'type' => 'shipping',
      'uid' => '3',
      'status' => '1',
      'created' => '1493287450',
      'changed' => '1493287450',
      'data' => NULL,
    ],
  ];
  $tests[0]['source_data']['field_config'] = [
    [
      'id' => '2',
      'field_name' => 'commerce_unit_price',
      'type' => 'commerce_price',
      'module' => 'commerce_price',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '1',
      'data' => 'a:6:{s:12:"entity_types";a:1:{i:0;s:18:"commerce_line_item";}s:12:"translatable";b:0;s:8:"settings";a:0:{}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";i:1;}s:12:"foreign keys";a:0:{}s:7:"indexes";a:1:{s:14:"currency_price";a:2:{i:0;s:6:"amount";i:1;s:13:"currency_code";}}}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
    ],
  ];
  $tests[0]['source_data']['field_config_instance'] = [
    [
      'id' => '2',
      'field_id' => '2',
      'field_name' => 'commerce_unit_price',
      'entity_type' => 'product',
      'bundle' => 'product',
      'data' => 'a:0:{};',
      'deleted' => '0',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'profile_id' => '1',
      'revision_id' => '1',
      'type' => 'billing',
      'uid' => '3',
      'status' => '1',
      'created' => '1493287440',
      'changed' => '1493287440',
      'data' => NULL,
    ],
  ];

  // Test with commerce_addressbook_default table.
  $tests[1] = $tests[0];
  $tests[1]['source_data']['commerce_addressbook_defaults'] = [
    [
      'cad_id' => '1',
      'profile_id' => '1',
      'type' => 'billing',
      'uid' => '3',
    ],
  ];

  // The expected results.
  $tests[1]['expected_data'][0]['cad_type'] = 'billing';
  return $tests;
}