Issue #3080163 by Mile23, voleger, Lendude, mondrake: Decouple TestFileCreationTrait::getTestFiles() from simpletest module

merge-requests/55/head
catch 2019-09-13 11:42:26 +01:00
parent c7ad1c70bd
commit 90a550d555
42 changed files with 40 additions and 40 deletions

View File

@ -67,7 +67,7 @@ class RelationshipUserFileDataTest extends ViewTestBase {
'status' => FILE_STATUS_PERMANENT,
]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
file_put_contents($file->getFileUri(), file_get_contents('core/tests/fixtures/files/image-1.png'));
$file->save();
$account = $this->drupalCreateUser();

View File

@ -107,7 +107,7 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
// File 2, when migrated for the second time, is treated as a different file
// (due to having a different uri this time) and is given fid 6.
$file = File::load(6);
$this->assertIdentical('public://core/modules/simpletest/files/image-2.jpg', $file->getFileUri());
$this->assertIdentical('public://core/tests/fixtures/files/image-2.jpg', $file->getFileUri());
$map_table = $this->getMigration('d6_file')->getIdMap()->mapTableName();
$map = \Drupal::database()
@ -146,7 +146,7 @@ class MigrateFileTest extends MigrateDrupal6TestBase implements MigrateDumpAlter
->condition('fid', 3)
->fields([
'filename' => 'image-3.jpg',
'filepath' => 'core/modules/simpletest/files/image-3.jpg',
'filepath' => 'core/tests/fixtures/files/image-3.jpg',
])
->execute();

View File

@ -40,7 +40,7 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
$this->drupalPostForm(NULL, [], t('Save'));
// Get invalid image test files from simpletest.
$dir = drupal_get_path('module', 'simpletest') . '/files';
$dir = 'core/tests/fixtures/files';
$files = [];
if (is_dir($dir)) {
$files = $file_system->scanDirectory($dir, '/invalid-img-.*/');

View File

@ -72,7 +72,7 @@ class RelationshipUserImageDataTest extends ViewsKernelTestBase {
'status' => FILE_STATUS_PERMANENT,
]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
file_put_contents($file->getFileUri(), file_get_contents('core/tests/fixtures/files/image-1.png'));
$file->save();
$account = User::create([

View File

@ -50,7 +50,7 @@ class FileCopyTest extends FileTestBase {
$data_sets = [
// Test a local to local copy.
[
$this->root . '/core/modules/simpletest/files/image-test.jpg',
$this->root . '/core/tests/fixtures/files/image-test.jpg',
'public://file1.jpg',
],
// Test a temporary file using an absolute path.
@ -61,7 +61,7 @@ class FileCopyTest extends FileTestBase {
// Test a temporary file using a relative path.
[
$file_absolute,
'temporary://core/modules/simpletest/files/test.jpg',
'temporary://core/tests/fixtures/files/test.jpg',
],
];
foreach ($data_sets as $data) {
@ -113,7 +113,7 @@ class FileCopyTest extends FileTestBase {
public function providerSuccessfulReuse() {
return [
[
'local_source_path' => static::getDrupalRoot() . '/core/modules/simpletest/files/image-test.jpg',
'local_source_path' => static::getDrupalRoot() . '/core/tests/fixtures/files/image-test.jpg',
'local_destination_path' => 'public://file1.jpg',
],
[
@ -146,7 +146,7 @@ class FileCopyTest extends FileTestBase {
// Test a temporary file using a relative path.
[
$file_2_absolute,
'temporary://core/modules/simpletest/files/test.jpg',
'temporary://core/tests/fixtures/files/test.jpg',
],
];
foreach ($data_sets as $data) {

View File

@ -8353,7 +8353,7 @@ $connection->insert('files')
'fid' => '1',
'uid' => '1',
'filename' => 'Image1.png',
'filepath' => 'core/modules/simpletest/files/image-1.png',
'filepath' => 'core/tests/fixtures/files/image-1.png',
'filemime' => 'image/png',
'filesize' => '39325',
'status' => '1',
@ -8363,7 +8363,7 @@ $connection->insert('files')
'fid' => '2',
'uid' => '1',
'filename' => 'Image2.jpg',
'filepath' => 'core/modules/simpletest/files/image-2.jpg',
'filepath' => 'core/tests/fixtures/files/image-2.jpg',
'filemime' => 'image/jpeg',
'filesize' => '1831',
'status' => '1',
@ -8373,7 +8373,7 @@ $connection->insert('files')
'fid' => '3',
'uid' => '1',
'filename' => 'Image-test.gif',
'filepath' => 'core/modules/simpletest/files/image-test.gif',
'filepath' => 'core/tests/fixtures/files/image-test.gif',
'filemime' => 'image/jpeg',
'filesize' => '183',
'status' => '1',
@ -8383,7 +8383,7 @@ $connection->insert('files')
'fid' => '5',
'uid' => '1',
'filename' => 'html-1.txt',
'filepath' => 'core/modules/simpletest/files/html-1.txt',
'filepath' => 'core/tests/fixtures/files/html-1.txt',
'filemime' => 'text/plain',
'filesize' => '24',
'status' => '1',
@ -33171,8 +33171,8 @@ $connection->insert('menu_links')
'menu_name' => 'navigation',
'mlid' => '411',
'plid' => '0',
'link_path' => 'core/modules/simpletest/files/imagecache',
'router_path' => 'core/modules/simpletest/files/imagecache',
'link_path' => 'core/tests/fixtures/files/imagecache',
'router_path' => 'core/tests/fixtures/files/imagecache',
'link_title' => '',
'options' => 'a:0:{}',
'module' => 'system',
@ -42845,7 +42845,7 @@ $connection->insert('menu_router')
'file' => 'sites/all/modules/cck/includes/content.node_form.inc',
))
->values(array(
'path' => 'core/modules/simpletest/files/imagecache',
'path' => 'core/tests/fixtures/files/imagecache',
'load_functions' => '',
'to_arg_functions' => '',
'access_callback' => '_imagecache_menu_access_public_files',
@ -42855,7 +42855,7 @@ $connection->insert('menu_router')
'fit' => '31',
'number_parts' => '5',
'tab_parent' => '',
'tab_root' => 'core/modules/simpletest/files/imagecache',
'tab_root' => 'core/tests/fixtures/files/imagecache',
'title' => '',
'title_callback' => 't',
'title_arguments' => '',
@ -48585,7 +48585,7 @@ $connection->insert('users')
'status' => '1',
'timezone' => '3600',
'language' => 'fr',
'picture' => 'core/modules/simpletest/files/image-test.jpg',
'picture' => 'core/tests/fixtures/files/image-test.jpg',
'init' => 'doe@example.com',
'data' => 'a:2:{s:7:"contact";i:1;s:13:"form_build_id";s:48:"form-qu_DMjE-Vfg01arT5J4VbuBCkOgx_LeySJx4qrPOSuA";}',
'timezone_name' => 'Europe/Berlin',
@ -48610,7 +48610,7 @@ $connection->insert('users')
'status' => '1',
'timezone' => '7200',
'language' => 'ro',
'picture' => 'core/modules/simpletest/files/image-test.png',
'picture' => 'core/tests/fixtures/files/image-test.png',
'init' => 'roe@example.com',
'data' => 'a:2:{s:7:"contact";i:0;s:13:"form_build_id";s:48:"form-1TxjbL2_1dEHIxEu2Db6OvEsSN1x9ILH1VCgnvsO6LE";}',
'timezone_name' => 'Europe/Helsinki',
@ -49567,7 +49567,7 @@ $connection->insert('variable')
))
->values(array(
'name' => 'file_directory_path',
'value' => 's:29:"core/modules/simpletest/files";',
'value' => 's:25:"core/tests/fixtures/files";',
))
->values(array(
'name' => 'file_directory_temp',

View File

@ -48,7 +48,7 @@ class MigrateUserTest extends MigrateDrupal6TestBase {
'status' => FILE_STATUS_PERMANENT,
]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-1.png'));
file_put_contents($file->getFileUri(), file_get_contents('core/tests/fixtures/files/image-1.png'));
$file->save();
$file = File::create([
@ -62,7 +62,7 @@ class MigrateUserTest extends MigrateDrupal6TestBase {
'status' => FILE_STATUS_PERMANENT,
]);
$file->enforceIsNew();
file_put_contents($file->getFileUri(), file_get_contents('core/modules/simpletest/files/image-2.jpg'));
file_put_contents($file->getFileUri(), file_get_contents('core/tests/fixtures/files/image-2.jpg'));
$file->save();
$this->executeMigration('language');

View File

@ -27,7 +27,7 @@ class UserPictureFileTest extends MigrateSqlSourceTestBase {
$tests[0]['source_data']['users'] = [
[
'uid' => '2',
'picture' => 'core/modules/simpletest/files/image-test.jpg',
'picture' => 'core/tests/fixtures/files/image-test.jpg',
],
[
'uid' => '15',
@ -39,7 +39,7 @@ class UserPictureFileTest extends MigrateSqlSourceTestBase {
$tests[0]['expected_data'] = [
[
'uid' => '2',
'picture' => 'core/modules/simpletest/files/image-test.jpg',
'picture' => 'core/tests/fixtures/files/image-test.jpg',
],
];

View File

@ -15,7 +15,7 @@ class PharWrapperTest extends KernelTestBase {
* Tests that only valid phar files can be used.
*/
public function testPharFile() {
$base = $this->getDrupalRoot() . '/core/modules/simpletest/files';
$base = $this->getDrupalRoot() . '/core/tests/fixtures/files';
// Ensure that file operations via the phar:// stream wrapper work for phar
// files with the .phar extension.
$this->assertFalse(file_exists("phar://$base/phar-1.phar/no-such-file.php"));

View File

@ -34,11 +34,11 @@ class ScanDirectoryTest extends FileTestBase {
*/
protected function setUp() {
parent::setUp();
// Hardcode the location of the simpletest files as it is already known
// Hardcode the location of the fixtures files as it is already known
// and shouldn't change, and we don't yet have a way to retrieve their
// location from drupal_get_filename() in a cached way.
// @todo Remove as part of https://www.drupal.org/node/2186491
$this->path = 'core/modules/simpletest/files';
$this->path = 'core/tests/fixtures/files';
$this->fileSystem = $this->container->get('file_system');
}

View File

@ -280,7 +280,7 @@ class ToolkitGdTest extends KernelTestBase {
foreach ($files as $file) {
foreach ($operations as $op => $values) {
// Load up a fresh image.
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
$image = $this->imageFactory->get('core/tests/fixtures/files/' . $file);
$toolkit = $image->getToolkit();
if (!$image->isValid()) {
$this->fail(new FormattableMarkup('Could not load image %file.', ['%file' => $file]));
@ -426,14 +426,14 @@ class ToolkitGdTest extends KernelTestBase {
*/
public function testResourceDestruction() {
// Test that an Image object going out of scope releases its GD resource.
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/image-test.png');
$image = $this->imageFactory->get('core/tests/fixtures/files/image-test.png');
$res = $image->getToolkit()->getResource();
$this->assertTrue(is_resource($res), 'Successfully loaded image resource.');
$image = NULL;
$this->assertFalse(is_resource($res), 'Image resource was destroyed after losing scope.');
// Test that 'create_new' operation does not leave orphaned GD resources.
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/image-test.png');
$image = $this->imageFactory->get('core/tests/fixtures/files/image-test.png');
$old_res = $image->getToolkit()->getResource();
// Check if resource has been created successfully.
$this->assertTrue(is_resource($old_res));
@ -456,7 +456,7 @@ class ToolkitGdTest extends KernelTestBase {
// Test loading an indexed GIF image with transparent color set.
// Color at top-right pixel should be fully transparent.
$file = 'image-test-transparent-indexed.gif';
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
$image = $this->imageFactory->get('core/tests/fixtures/files/' . $file);
$resource = $image->getToolkit()->getResource();
$color_index = imagecolorat($resource, $image->getWidth() - 1, 0);
$color = array_values(imagecolorsforindex($resource, $color_index));
@ -490,14 +490,14 @@ class ToolkitGdTest extends KernelTestBase {
// of 6 colors, and setting the transparent color index to 6 (one higher
// than the largest allowed index), as follows:
// @code
// $image = imagecreatefromgif('core/modules/simpletest/files/image-test.gif');
// $image = imagecreatefromgif('core/tests/fixtures/files/image-test.gif');
// imagecolortransparent($image, 6);
// imagegif($image, 'core/modules/simpletest/files/image-test-transparent-out-of-range.gif');
// imagegif($image, 'core/tests/fixtures/files/image-test-transparent-out-of-range.gif');
// @endcode
// This allows us to test that an image with an out-of-range color index
// can be loaded correctly.
$file = 'image-test-transparent-out-of-range.gif';
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
$image = $this->imageFactory->get('core/tests/fixtures/files/' . $file);
$toolkit = $image->getToolkit();
if (!$image->isValid()) {
@ -522,7 +522,7 @@ class ToolkitGdTest extends KernelTestBase {
$file = 'image-test.png';
// Load up a fresh image.
$image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
$image = $this->imageFactory->get('core/tests/fixtures/files/' . $file);
if (!$image->isValid()) {
$this->fail(new FormattableMarkup('Could not load image %file.', ['%file' => $file]));
}

View File

@ -26,9 +26,9 @@ class InstallerLanguageTest extends KernelTestBase {
'it' => [],
];
// Hardcode the simpletest module location as we don't yet know where it is.
// Hardcode the fixtures location as we don't yet know where it is.
// @todo Remove as part of https://www.drupal.org/node/2186491
$file_translation = new FileTranslation('core/modules/simpletest/files/translations', $this->container->get('file_system'));
$file_translation = new FileTranslation('core/tests/fixtures/files/translations', $this->container->get('file_system'));
foreach ($expected_translation_files as $langcode => $files_expected) {
$files_found = $file_translation->findTranslationFiles($langcode);
$this->assertTrue(count($files_found) == count($files_expected), new FormattableMarkup('@count installer languages found.', ['@count' => count($files_expected)]));

View File

@ -24,7 +24,7 @@ trait TestFileCreationTrait {
* The first time this method is called, it will call
* $this->generateFile() to generate binary and ASCII text files in the
* public:// directory. It will also copy all files in
* core/modules/simpletest/files to public://. These contain image, SQL, PHP,
* core/tests/fixtures/files to public://. These contain image, SQL, PHP,
* JavaScript, and HTML files.
*
* All filenames are prefixed with their type and have appropriate extensions:
@ -69,8 +69,8 @@ trait TestFileCreationTrait {
$this->generateFile('text-' . $count++, 64, $line, 'text');
}
// Copy other test files from simpletest.
$original = drupal_get_path('module', 'simpletest') . '/files';
// Copy other test files from fixtures.
$original = \Drupal::service('app.root') . '/core/tests/fixtures/files';
$files = $file_system->scanDirectory($original, '/(html|image|javascript|php|sql)-.*/');
foreach ($files as $file) {
$file_system->copy($file->uri, PublicStream::basePath());

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 964 B

After

Width:  |  Height:  |  Size: 964 B

View File

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 140 B

View File

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 183 B

View File

Before

Width:  |  Height:  |  Size: 183 B

After

Width:  |  Height:  |  Size: 183 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 125 B

After

Width:  |  Height:  |  Size: 125 B