You are here

public function UploadTest::providerSource in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/tests/src/Kernel/Plugin/migrate/source/d6/UploadTest.php \Drupal\Tests\file\Kernel\Plugin\migrate\source\d6\UploadTest::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

core/modules/file/tests/src/Kernel/Plugin/migrate/source/d6/UploadTest.php, line 24

Class

UploadTest
Tests D6 d6_upload source plugin.

Namespace

Drupal\Tests\file\Kernel\Plugin\migrate\source\d6

Code

public function providerSource() {
  $tests = [];

  // The source data.
  $tests[0]['source_data']['upload'] = [
    [
      'fid' => '1',
      'nid' => '1',
      'vid' => '1',
      'description' => 'file 1-1-1',
      'list' => '0',
      'weight' => '-1',
    ],
    [
      'fid' => '3',
      'nid' => '12',
      'vid' => '15',
      'description' => 'file 12-15-3',
      'list' => '0',
      'weight' => '0',
    ],
  ];
  $tests[0]['source_data']['node'] = [
    [
      'nid' => '1',
      'vid' => '1',
      'type' => 'story',
      'language' => '',
      'title' => 'Test title',
      'uid' => '1',
      'status' => '1',
      'created' => '1388271197',
      'changed' => '1420861423',
      'comment' => '0',
      'promote' => '0',
      'moderate' => '0',
      'sticky' => '0',
      'tnid' => '0',
      'translate' => '0',
    ],
    [
      'nid' => '12',
      'vid' => '15',
      'type' => 'page',
      'language' => 'zu',
      'title' => 'Abantu zulu',
      'uid' => '1',
      'status' => '1',
      'created' => '1444238800',
      'changed' => '1444238808',
      'comment' => '0',
      'promote' => '0',
      'moderate' => '0',
      'sticky' => '0',
      'tnid' => '12',
      'translate' => '0',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'upload' => [
        [
          'fid' => '1',
          'description' => 'file 1-1-1',
          'list' => '0',
        ],
      ],
      'language' => '',
      'nid' => '1',
      'vid' => '1',
      'type' => 'story',
    ],
    [
      'upload' => [
        [
          'fid' => '3',
          'description' => 'file 12-15-3',
          'list' => '0',
        ],
      ],
      'language' => 'zu',
      'nid' => '12',
      'vid' => '15',
      'type' => 'page',
    ],
  ];
  return $tests;
}