X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffile%2Ftests%2Fsrc%2FKernel%2FPlugin%2Fmigrate%2Fsource%2Fd7%2FFileTest.php;fp=web%2Fcore%2Fmodules%2Ffile%2Ftests%2Fsrc%2FKernel%2FPlugin%2Fmigrate%2Fsource%2Fd7%2FFileTest.php;h=b588ad789ce5ad19fc99c6be45f4b8dd7b8a57d1;hp=8ae0ec41fa16257c0c684b4aa43f217199304309;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php b/web/core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php index 8ae0ec41f..b588ad789 100644 --- a/web/core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php +++ b/web/core/modules/file/tests/src/Kernel/Plugin/migrate/source/d7/FileTest.php @@ -84,15 +84,14 @@ class FileTest extends MigrateSqlSourceTestBase { ], ]; - // The expected results will include only the first three files, since we - // are configuring the plugin to filter out the file with the null URI - // scheme. - $tests[0]['expected_data'] = array_slice($tests[0]['source_data']['file_managed'], 0, 3); + // The expected results will include only the first two files, since the + // plugin will filter out files with either the null URI scheme or the + // temporary scheme. + $tests[0]['expected_data'] = array_slice($tests[0]['source_data']['file_managed'], 0, 2); // The filepath property will vary by URI scheme. $tests[0]['expected_data'][0]['filepath'] = 'sites/default/files/cube.jpeg'; $tests[0]['expected_data'][1]['filepath'] = '/path/to/private/files/cube.jpeg'; - $tests[0]['expected_data'][2]['filepath'] = '/tmp/cube.jpeg'; // Do an automatic count. $tests[0]['expected_count'] = NULL; @@ -102,10 +101,61 @@ class FileTest extends MigrateSqlSourceTestBase { 'constants' => [ 'source_base_path' => '/path/to/files', ], - // Only return files which use one of these URI schemes. 'scheme' => ['public', 'private', 'temporary'], ]; + // Test getting only public files. + $tests[1]['source_data'] = $tests[0]['source_data']; + + $tests[1]['expected_data'] = [ + [ + 'fid' => '1', + 'uid' => '1', + 'filename' => 'cube.jpeg', + 'uri' => 'public://cube.jpeg', + 'filemime' => 'image/jpeg', + 'filesize' => '3620', + 'status' => '1', + 'timestamp' => '1421727515', + ], + ]; + // Do an automatic count. + $tests[1]['expected_count'] = NULL; + + // Set up plugin configuration. + $tests[1]['configuration'] = [ + 'constants' => [ + 'source_base_path' => '/path/to/files', + ], + 'scheme' => ['public'], + ]; + + // Test getting only public files when configuration scheme is not an array. + $tests[2]['source_data'] = $tests[0]['source_data']; + + $tests[2]['expected_data'] = [ + [ + 'fid' => '1', + 'uid' => '1', + 'filename' => 'cube.jpeg', + 'uri' => 'public://cube.jpeg', + 'filemime' => 'image/jpeg', + 'filesize' => '3620', + 'status' => '1', + 'timestamp' => '1421727515', + ], + ]; + // Do an automatic count. + $tests[2]['expected_count'] = NULL; + + // Set up plugin configuration. + $tests[2]['configuration'] = [ + 'constants' => [ + 'source_base_path' => '/path/to/files', + ], + 'scheme' => 'public', + ]; + return $tests; }