You are here

public function FileEntityItemTest::providerSource in Media Migration 8

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

tests/src/Kernel/Plugin/migrate/source/d7/FileEntityItemTest.php, line 46

Class

FileEntityItemTest
Tests the file entiy item source plugin.

Namespace

Drupal\Tests\media_migration\Kernel\Plugin\migrate\source\d7

Code

public function providerSource() {
  return [
    'No filtering' => [
      'source' => self::SOURCE_DATABASE,
      'expected' => [
        [
          'fid' => 1,
          'uid' => 1,
          'filename' => 'Blue PNG',
          'uri' => 'public://blue.png',
          'filemime' => 'image/png',
          'filesize' => 9061,
          'status' => 1,
          'timestamp' => 1587725909,
          'type' => 'image',
          'scheme' => 'public',
          'bundle' => 'image',
        ],
        [
          'fid' => 3,
          'uid' => 1,
          'filename' => 'red.jpeg',
          'uri' => 'public://red.jpeg',
          'filemime' => 'image/jpeg',
          'filesize' => 19098,
          'status' => 1,
          'timestamp' => 1587726037,
          'type' => 'image',
          'scheme' => 'public',
          'bundle' => 'image',
        ],
        [
          'fid' => 4,
          'uid' => 1,
          'filename' => 'DrupalCon Amsterdam 2019: Keynote - Driesnote',
          'uri' => 'youtube://v/Apqd4ff0NRI',
          'filemime' => 'video/youtube',
          'filesize' => 0,
          'status' => 1,
          'timestamp' => 1587726087,
          'type' => 'video',
          'scheme' => 'youtube',
          'bundle' => 'video_youtube',
        ],
        [
          'fid' => 2,
          'uid' => 1,
          'filename' => 'green.jpg',
          'uri' => 'public://field/image/green.jpg',
          'filemime' => 'image/jpeg',
          'filesize' => 11050,
          'status' => 1,
          'timestamp' => 1587730322,
          'type' => 'image',
          'scheme' => 'public',
          'bundle' => 'image',
        ],
        [
          'fid' => '5',
          'uid' => '1',
          'filename' => 'Responsive Images in Drupal 8',
          'uri' => 'vimeo://v/204517230',
          'filemime' => 'video/vimeo',
          'filesize' => '0',
          'status' => '1',
          'timestamp' => '1587730964',
          'type' => 'video',
          'scheme' => 'vimeo',
          'bundle' => 'video_vimeo',
        ],
        [
          'fid' => '6',
          'uid' => '1',
          'filename' => 'LICENSE.txt',
          'uri' => 'public://LICENSE.txt',
          'filemime' => 'text/plain',
          'filesize' => '18002',
          'status' => '1',
          'timestamp' => '1587731111',
          'type' => 'document',
          'scheme' => 'public',
          'bundle' => 'document',
        ],
        [
          'fid' => '7',
          'uid' => '2',
          'filename' => 'yellow.jpg',
          'uri' => 'public://field/image/yellow.jpg',
          'filemime' => 'image/jpeg',
          'filesize' => '5363',
          'status' => '1',
          'timestamp' => '1588600435',
          'type' => 'image',
          'scheme' => 'public',
          'bundle' => 'image',
        ],
        [
          'fid' => '8',
          'uid' => '2',
          'filename' => 'video.webm',
          'uri' => 'public://video.webm',
          'filemime' => 'video/webm',
          'filesize' => '18123',
          'status' => '1',
          'timestamp' => '1594037784',
          'type' => 'video',
          'scheme' => 'public',
          'bundle' => 'video',
        ],
        [
          'fid' => '9',
          'uid' => '2',
          'filename' => 'video.mp4',
          'uri' => 'public://video.mp4',
          'filemime' => 'video/mp4',
          'filesize' => '18011',
          'status' => '1',
          'timestamp' => '1594117700',
          'type' => 'video',
          'scheme' => 'public',
          'bundle' => 'video',
        ],
        [
          'fid' => '10',
          'uid' => '2',
          'filename' => 'yellow.webp',
          'uri' => 'public://yellow.webp',
          'filemime' => 'image/webp',
          'filesize' => '3238',
          'status' => '1',
          'timestamp' => '1594191582',
          'type' => 'image',
          'scheme' => 'public',
          'bundle' => 'image',
        ],
        [
          'fid' => '11',
          'uid' => '1',
          'filename' => 'audio.m4a',
          'uri' => 'public://audio.m4a',
          'filemime' => 'audio/mpeg',
          'filesize' => '10711',
          'status' => '1',
          'timestamp' => '1594193701',
          'type' => 'audio',
          'scheme' => 'public',
          'bundle' => 'audio',
        ],
        [
          'fid' => '12',
          'uid' => '2',
          'filename' => 'document.odt',
          'uri' => 'public://document.odt',
          'filemime' => 'application/vnd.oasis.opendocument.text',
          'filesize' => '8089',
          'status' => '1',
          'timestamp' => '1594201103',
          'type' => 'document',
          'scheme' => 'public',
          'bundle' => 'document',
        ],
      ],
      'count' => 12,
      'config' => [],
    ],
    'Filtering for type "video"' => [
      'source' => self::SOURCE_DATABASE,
      'expected' => [
        [
          'fid' => '4',
          'uid' => '1',
          'filename' => 'DrupalCon Amsterdam 2019: Keynote - Driesnote',
          'uri' => 'youtube://v/Apqd4ff0NRI',
          'filemime' => 'video/youtube',
          'filesize' => '0',
          'status' => '1',
          'timestamp' => '1587726087',
          'type' => 'video',
          'scheme' => 'youtube',
          'bundle' => 'video_youtube',
        ],
        [
          'fid' => '5',
          'uid' => '1',
          'filename' => 'Responsive Images in Drupal 8',
          'uri' => 'vimeo://v/204517230',
          'filemime' => 'video/vimeo',
          'filesize' => '0',
          'status' => '1',
          'timestamp' => '1587730964',
          'type' => 'video',
          'scheme' => 'vimeo',
          'bundle' => 'video_vimeo',
        ],
        [
          'fid' => '8',
          'uid' => '2',
          'filename' => 'video.webm',
          'uri' => 'public://video.webm',
          'filemime' => 'video/webm',
          'filesize' => '18123',
          'status' => '1',
          'timestamp' => '1594037784',
          'type' => 'video',
          'scheme' => 'public',
          'bundle' => 'video',
        ],
        [
          'fid' => '9',
          'uid' => '2',
          'filename' => 'video.mp4',
          'uri' => 'public://video.mp4',
          'filemime' => 'video/mp4',
          'filesize' => '18011',
          'status' => '1',
          'timestamp' => '1594117700',
          'type' => 'video',
          'scheme' => 'public',
          'bundle' => 'video',
        ],
      ],
      'count' => 4,
      'config' => [
        'type' => 'video',
      ],
    ],
    'Filtering for scheme "youtube"' => [
      'source' => self::SOURCE_DATABASE,
      'expected' => [
        [
          'fid' => '4',
          'uid' => '1',
          'filename' => 'DrupalCon Amsterdam 2019: Keynote - Driesnote',
          'uri' => 'youtube://v/Apqd4ff0NRI',
          'filemime' => 'video/youtube',
          'filesize' => '0',
          'status' => '1',
          'timestamp' => '1587726087',
          'type' => 'video',
          'scheme' => 'youtube',
          'bundle' => 'video_youtube',
        ],
      ],
      'count' => 1,
      'config' => [
        'scheme' => 'youtube',
      ],
    ],
    'Filtering for uri prefix "youtube"' => [
      'source' => self::SOURCE_DATABASE,
      'expected' => [
        [
          'fid' => '4',
          'uid' => '1',
          'filename' => 'DrupalCon Amsterdam 2019: Keynote - Driesnote',
          'uri' => 'youtube://v/Apqd4ff0NRI',
          'filemime' => 'video/youtube',
          'filesize' => '0',
          'status' => '1',
          'timestamp' => '1587726087',
          'type' => 'video',
          'scheme' => 'youtube',
          'bundle' => 'video_youtube',
          'uri_prefix' => 'youtube',
        ],
      ],
      'count' => 1,
      'config' => [
        'uri_prefix' => 'youtube',
      ],
    ],
    'Filtering for uri prefix "vimeo://"' => [
      'source' => self::SOURCE_DATABASE,
      'expected' => [
        [
          'fid' => '5',
          'uid' => '1',
          'filename' => 'Responsive Images in Drupal 8',
          'uri' => 'vimeo://v/204517230',
          'filemime' => 'video/vimeo',
          'filesize' => '0',
          'status' => '1',
          'timestamp' => '1587730964',
          'type' => 'video',
          'scheme' => 'vimeo',
          'bundle' => 'video_vimeo',
          'uri_prefix' => 'vimeo://',
        ],
      ],
      'count' => 1,
      'config' => [
        'uri_prefix' => 'vimeo://',
      ],
    ],
  ];
}