You are here

public function NodeTest::providerSource in Commerce Migrate 3.0.x

Same name and namespace in other branches
  1. 8.2 modules/ubercart/tests/src/Kernel/Plugin/migrate/source/uc6/NodeTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source\uc6\NodeTest::providerSource()
  2. 3.1.x modules/ubercart/tests/src/Kernel/Plugin/migrate/source/uc6/NodeTest.php \Drupal\Tests\commerce_migrate_ubercart\Kernel\Plugin\migrate\source\uc6\NodeTest::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/uc6/NodeTest.php, line 30

Class

NodeTest
Tests Ubercart 6 product source plugin.

Namespace

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

Code

public function providerSource() {
  $tests = [];
  $tests[0]['source_data']['node'] = [
    [
      'nid' => 1,
      'vid' => 1,
      'type' => 'page',
      'language' => 'en',
      'title' => 'node title 1',
      'uid' => 1,
      'status' => 1,
      'created' => 1279051598,
      'changed' => 1279051598,
      'comment' => 2,
      'promote' => 1,
      'moderate' => 0,
      'sticky' => 0,
      'translate' => 0,
      'tnid' => 0,
    ],
    [
      'nid' => 2,
      'vid' => 2,
      'type' => 'product',
      'language' => 'en',
      'title' => 'T Shirt',
      'uid' => 1,
      'status' => 1,
      'created' => 1279290908,
      'changed' => 1279308993,
      'comment' => 0,
      'promote' => 1,
      'moderate' => 0,
      'sticky' => 0,
      'translate' => 0,
      'tnid' => 0,
    ],
    [
      'nid' => 5,
      'vid' => 5,
      'type' => 'ship',
      'language' => 'en',
      'title' => 'Bag',
      'uid' => 1,
      'status' => 1,
      'created' => 1279290908,
      'changed' => 1279308993,
      'comment' => 0,
      'promote' => 1,
      'moderate' => 0,
      'sticky' => 0,
      'translate' => 0,
      'tnid' => 0,
    ],
  ];
  $tests[0]['source_data']['node_revisions'] = [
    [
      'nid' => 1,
      'vid' => 1,
      'uid' => 2,
      'title' => 'node title 1',
      'body' => 'body for node 1',
      'teaser' => 'teaser for node 1',
      'log' => '',
      'format' => 1,
      'timestamp' => 1279051598,
    ],
    [
      'nid' => 2,
      'vid' => 2,
      'uid' => 2,
      'title' => 'T Shirt',
      'body' => 'body for node 2',
      'teaser' => 'teaser for node 2',
      'log' => '',
      'format' => 1,
      'timestamp' => 1279308993,
    ],
    [
      'nid' => 5,
      'vid' => 5,
      'uid' => 2,
      'title' => 'Bag',
      'body' => 'body for node 5',
      'teaser' => 'teaser for node 5',
      'log' => '',
      'format' => 1,
      'timestamp' => 1279308993,
    ],
  ];
  $tests[0]['source_data']['uc_products'] = [
    [
      'vid' => '2',
      'nid' => '2',
      'model' => 'item1',
      'list_price' => '30.0000',
      'cost' => '25.0000',
      'sell_price' => '40.000',
      'weight' => '2',
      'weight_units' => 'g',
      'length' => '12',
      'width' => '13',
      'height' => '14',
      'length_units' => 'cm',
      'pkg_qty' => '1',
      'default_qty' => '1',
      'ordering' => '0',
      'shippable' => '1',
    ],
    [
      'vid' => '5',
      'nid' => '5',
      'model' => 'item2',
      'list_price' => '40.0000',
      'cost' => '45.0000',
      'sell_price' => '50.000',
      'weight' => '5',
      'weight_units' => 'g',
      'length' => '22',
      'width' => '23',
      'height' => '24',
      'length_units' => 'cm',
      'pkg_qty' => '1',
      'default_qty' => '1',
      'ordering' => '0',
      'shippable' => '1',
    ],
  ];
  $tests[0]['expected_data'] = [
    [
      'nid' => 2,
      'vid' => 2,
      'type' => 'product',
      'title' => 'T Shirt',
      'status' => 1,
      'created' => 1279290908,
      'changed' => 1279308993,
      'body' => 'body for node 2',
      'teaser' => 'teaser for node 2',
      'model' => 'item1',
      'sell_price' => '40.000',
    ],
    [
      'nid' => 5,
      'vid' => 5,
      'type' => 'ship',
      'title' => 'Bag',
      'status' => 1,
      'created' => 1279290908,
      'changed' => 1279308993,
      'body' => 'body for node 5',
      'teaser' => 'teaser for node 5',
      'model' => 'item2',
      'sell_price' => '50.000',
    ],
  ];
  $tests[1]['source_data'] = $tests[0]['source_data'];
  $tests[1]['expected_data'] = [
    [
      'nid' => 5,
      'vid' => 5,
      'type' => 'ship',
      'title' => 'Bag',
      'status' => 1,
      'created' => 1279290908,
      'changed' => 1279308993,
      'body' => 'body for node 5',
      'teaser' => 'teaser for node 5',
      'model' => 'item2',
      'sell_price' => '50.000',
    ],
  ];
  $tests[1]['expected_count'] = NULL;
  $tests[1]['configuration']['node_type'] = 'ship';
  return $tests;
}