You are here

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

Same name in this branch
  1. 3.1.x modules/ubercart/tests/src/Kernel/Plugin/migrate/source/uc7/FieldTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source\uc7\FieldTest::providerSource()
  2. 3.1.x modules/commerce/tests/src/Kernel/Plugin/migrate/source/commerce1/FieldTest.php \Drupal\Tests\commerce_migrate_commerce\Kernel\Plugin\migrate\source\commerce1\FieldTest::providerSource()
Same name and namespace in other branches
  1. 8.2 modules/ubercart/tests/src/Kernel/Plugin/migrate/source/uc7/FieldTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source\uc7\FieldTest::providerSource()
  2. 3.0.x modules/ubercart/tests/src/Kernel/Plugin/migrate/source/uc7/FieldTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source\uc7\FieldTest::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/ubercart/tests/src/Kernel/Plugin/migrate/source/uc7/FieldTest.php, line 33

Class

FieldTest
Tests the Ubercart 7 field source plugin.

Namespace

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

Code

public function providerSource() {
  $tests = [
    [
      'source_data' => [],
      'expected_data' => [],
    ],
  ];

  // The source data. Tests with a field, test_field, on a non product node
  // and a product node, a field only on a non product nodes and a field only
  // on a product node.
  $tests[0]['source_data']['node_type'] = [
    [
      'type' => 'page',
      'name' => 'Page',
      'module' => 'node',
      'description' => 'A page',
      'help' => '',
      'title_label' => 'Title',
      'has_body' => 1,
      'body_label' => 'Body',
      'min_word_count' => 0,
      'custom' => 1,
      'modified' => 0,
      'locked' => 0,
      'orig_type' => 'page',
    ],
    [
      'type' => 'product',
      'name' => 'Product',
      'module' => 'uc_product',
      'description' => 'product',
      'help' => '',
      'title_label' => 'Title',
      'has_body' => 1,
      'body_label' => 'Body',
      'min_word_count' => 0,
      'custom' => 1,
      'modified' => 0,
      'locked' => 0,
      'orig_type' => 'product',
    ],
    [
      'type' => 'product_kit',
      'name' => 'Product Kit',
      'module' => 'uc_product_kit',
      'description' => 'A product group',
      'help' => '',
      'title_label' => 'Title',
      'has_body' => 1,
      'body_label' => 'Body',
      'min_word_count' => 0,
      'custom' => 1,
      'modified' => 0,
      'locked' => 0,
      'orig_type' => 'product_kit',
    ],
  ];
  $tests[0]['source_data']['field_config'] = [
    [
      'id' => '1',
      'field_name' => 'field_test',
      'type' => 'file',
      'module' => 'file',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '0',
      'data' => 'a:0:{}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
    ],
    [
      'id' => '2',
      'field_name' => 'field_image',
      'type' => 'file',
      'module' => 'file',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '0',
      'data' => 'a:0:{}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
    ],
    [
      'id' => '3',
      'field_name' => 'field_picture',
      'type' => 'file',
      'module' => 'file',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '0',
      'data' => 'a:0:{}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
    ],
  ];
  $tests[0]['source_data']['field_config_instance'] = [
    [
      'id' => '33',
      'field_id' => '1',
      'field_name' => 'field_test',
      'entity_type' => 'node',
      'bundle' => 'page',
      'data' => 'a:0:{}',
      'deleted' => '0',
    ],
    [
      'id' => '21',
      'field_id' => '1',
      'field_name' => 'field_test',
      'entity_type' => 'node',
      'bundle' => 'product_kit',
      'data' => 'a:0:{}',
      'deleted' => '0',
    ],
    [
      'id' => '22',
      'field_id' => '2',
      'field_name' => 'field_image',
      'entity_type' => 'node',
      'bundle' => 'page',
      'data' => 'a:0:{}',
      'deleted' => '0',
    ],
    [
      'id' => '23',
      'field_id' => '3',
      'field_name' => 'field_picture',
      'entity_type' => 'node',
      'bundle' => 'product_kit',
      'data' => 'a:0:{}',
      'deleted' => '0',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'id' => '1',
      'field_name' => 'field_test',
      'type' => 'file',
      'module' => 'file',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '0',
      'data' => 'a:0:{}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
      'entity_type' => 'node',
      'commerce_product' => 1,
    ],
    [
      'id' => '1',
      'field_name' => 'field_test',
      'type' => 'file',
      'module' => 'file',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '0',
      'data' => 'a:0:{}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
      'entity_type' => 'node',
      'commerce_product' => 0,
    ],
    [
      'id' => '2',
      'field_name' => 'field_image',
      'type' => 'file',
      'module' => 'file',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '0',
      'data' => 'a:0:{}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
      'entity_type' => 'node',
      'commerce_product' => 0,
    ],
    [
      'id' => '3',
      'field_name' => 'field_picture',
      'type' => 'file',
      'module' => 'file',
      'active' => '1',
      'storage_type' => 'field_sql_storage',
      'storage_module' => 'field_sql_storage',
      'storage_active' => '1',
      'locked' => '0',
      'data' => 'a:0:{}',
      'cardinality' => '1',
      'translatable' => '0',
      'deleted' => '0',
      'entity_type' => 'node',
      'commerce_product' => 1,
    ],
  ];

  // Initialize iterator adds a row, one more than the query count.
  $tests[0]['expected_count'] = 3;
  return $tests;
}