You are here

public function MigrateSpreadsheetTest::pluginTestProvider in Migrate Spreadsheet 2.0.x

Provides testing cases for ::testPlugin() test.

Return value

\string[][] Test cases.

File

tests/src/Kernel/MigrateSpreadsheetTest.php, line 60

Class

MigrateSpreadsheetTest
Tests the 'spreadsheet' migrate source plugin.

Namespace

Drupal\Tests\migrate_spreadsheet\Kernel

Code

public function pluginTestProvider() : array {
  $configuration = [
    'source' => [
      'plugin' => 'spreadsheet',
      'worksheet' => 'Sheet1',
      'origin' => 'B3',
      'header_row' => 2,
      'columns' => [
        'ID',
        'Name',
      ],
      'keys' => [
        'ID' => [
          'type' => 'integer',
          'size' => 'big',
        ],
      ],
    ],
    'process' => [
      'id' => 'ID',
      'name' => 'Name',
    ],
    'destination' => [
      'plugin' => 'entity:entity_test',
    ],
  ];
  $files = [
    'Open Document Format/OASIS (.ods)' => 'test.ods',
    'Office Open XML (.xlsx) Excel 2007 and above' => 'test.xlsx',
    'BIFF 8 (.xls) Excel 97 and above' => 'test.xls',
    'BIFF 5 (.xls) Excel 95' => 'test_excel5.xls',
    'SpreadsheetML (.xml) Excel 2003' => 'test.xml',
    'SYLK' => 'test.slk',
    'CSV' => 'test.csv',
  ];
  return array_map(function (string $filename) use ($configuration) : array {
    $configuration['source']['file'] = __DIR__ . "/../../fixtures/{$filename}";
    return [
      $configuration,
    ];
  }, $files);
}