3 namespace Drupal\Tests\file\Kernel\Plugin\migrate\source\d7;
5 use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
8 * Tests D7 file source plugin.
10 * @covers \Drupal\file\Plugin\migrate\source\d7\File
13 class FileTest extends MigrateSqlSourceTestBase {
18 public static $modules = ['file', 'migrate_drupal'];
23 public function providerSource() {
26 $tests[0]['source_data']['file_managed'] = [
31 'filename' => 'cube.jpeg',
32 'uri' => 'public://cube.jpeg',
33 'filemime' => 'image/jpeg',
36 'timestamp' => '1421727515',
42 'filename' => 'cube.jpeg',
43 'uri' => 'private://cube.jpeg',
44 'filemime' => 'image/jpeg',
47 'timestamp' => '1421727515',
53 'filename' => 'cube.jpeg',
54 'uri' => 'temporary://cube.jpeg',
55 'filemime' => 'image/jpeg',
58 'timestamp' => '1421727515',
60 // A file with a URI scheme that will be filtered out.
64 'filename' => 'cube.jpeg',
65 'uri' => 'null://cube.jpeg',
66 'filemime' => 'image/jpeg',
69 'timestamp' => '1421727515',
72 $tests[0]['source_data']['variable'] = [
74 'name' => 'file_public_path',
75 'value' => serialize('sites/default/files'),
78 'name' => 'file_private_path',
79 'value' => serialize('/path/to/private/files'),
82 'name' => 'file_temporary_path',
83 'value' => serialize('/tmp'),
87 // The expected results will include only the first three files, since we
88 // are configuring the plugin to filter out the file with the null URI
90 $tests[0]['expected_data'] = array_slice($tests[0]['source_data']['file_managed'], 0, 3);
92 // The filepath property will vary by URI scheme.
93 $tests[0]['expected_data'][0]['filepath'] = 'sites/default/files/cube.jpeg';
94 $tests[0]['expected_data'][1]['filepath'] = '/path/to/private/files/cube.jpeg';
95 $tests[0]['expected_data'][2]['filepath'] = '/tmp/cube.jpeg';
97 // Do an automatic count.
98 $tests[0]['expected_count'] = NULL;
100 // Set up plugin configuration.
101 $tests[0]['configuration'] = [
103 'source_base_path' => '/path/to/files',
105 // Only return files which use one of these URI schemes.
106 'scheme' => ['public', 'private', 'temporary'],