You are here

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

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

See also

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

File

modules/commerce/tests/src/Kernel/Plugin/migrate/source/commerce1/ProfileRevisionTest.php, line 23

Class

ProfileRevisionTest
Tests the profile revision source plugin.

Namespace

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

Code

public function providerSource() {
  $tests = parent::providerSource();

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'profile_id' => '2',
      'revision_id' => '3',
      'type' => 'shipping',
      'uid' => '5',
      'status' => '1',
      'created' => '1493287441',
      'changed' => '1493287551',
      'data' => unserialize('a:1:{s:4:"ship";s:9:"andromeda";}'),
      'cad_type' => 'shipping',
      'commerce_customer_address' => [
        [
          'country' => 'US',
          'administrative_area' => 'CA',
        ],
      ],
      'revision_uid' => '1',
      'log' => '',
      'revision_timestamp' => '1493287451',
      'revision_status' => '9',
      'revision_data' => unserialize('a:1:{s:4:"ship";s:7:"defiant";}'),
    ],
  ];
  $tests[0]['expected_count'] = NULL;
  $tests[0]['configuration']['profile_type'] = [
    'billing',
    'shipping',
  ];

  // Repeat test0 without the commerce_addresbook_defaults table.
  $tests[1] = $tests[0];
  unset($tests[1]['source_data']['commerce_addressbook_defaults']);
  $tests[1]['expected_data'][0]['cad_type'] = NULL;
  $tests[1]['expected_data'][0]['revision_timestamp'] = '1493287451';
  $tests[1]['expected_data'][0]['log'] = NULL;
  unset($tests[1]['expected_data'][1]);

  // Repeat test0 configuration profile_type as a string.
  $tests[2] = $tests[0];

  // The expected results.
  $tests[2]['expected_data'] = [
    [
      'profile_id' => '2',
      'revision_id' => '3',
      'type' => 'shipping',
      'uid' => '5',
      'status' => '1',
      'created' => '1493287441',
      'changed' => '1493287551',
      'data' => unserialize('a:1:{s:4:"ship";s:9:"andromeda";}'),
      'cad_type' => 'shipping',
      'commerce_customer_address' => [
        [
          'country' => 'US',
          'administrative_area' => 'CA',
        ],
      ],
      'revision_uid' => '1',
      'log' => '',
      'revision_timestamp' => '1493287451',
      'revision_status' => '9',
      'revision_data' => unserialize('a:1:{s:4:"ship";s:7:"defiant";}'),
    ],
  ];
  $tests[2]['configuration']['profile_type'] = 'shipping';
  return $tests;
}