diff --git a/core/modules/file/src/Tests/SaveUploadTest.php b/core/modules/file/src/Tests/SaveUploadTest.php index 30e681d..50f7795 100644 --- a/core/modules/file/src/Tests/SaveUploadTest.php +++ b/core/modules/file/src/Tests/SaveUploadTest.php @@ -33,8 +33,12 @@ protected function setUp() { $account = $this->drupalCreateUser(); $this->drupalLogin($account); - $image_files = $this->drupalGetTestFiles('image'); - $this->image = entity_create('file', (array) current($image_files)); + foreach ($this->drupalGetTestFiles('image') as $image_file) { + if ($image_file->filename == 'image-test.png') { + break; + } + } + $this->image = entity_create('file', (array) $image_file); list(, $this->image_extension) = explode('.', $this->image->getFilename()); $this->assertTrue(is_file($this->image->getFileUri()), "The image file we're going to upload exists."); @@ -74,7 +78,11 @@ function testNormal() { file_test_reset(); // Upload a second file. - $image2 = current($this->drupalGetTestFiles('image')); + foreach ($this->drupalGetTestFiles('image') as $image2) { + if ($image2->filename == 'image-test.png') { + break; + } + } $edit = array('files[file_test_upload]' => drupal_realpath($image2->uri)); $this->drupalPostForm('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, 'Received a 200 response for posted test file.'); @@ -95,7 +103,11 @@ function testNormal() { $this->assertTrue(isset($files[$file2->id()]), 'File was loaded successfully'); // Upload a third file to a subdirectory. - $image3 = current($this->drupalGetTestFiles('image')); + foreach ($this->drupalGetTestFiles('image') as $image3) { + if ($image3->filename == 'image-test.png') { + break; + } + } $image3_realpath = drupal_realpath($image3->uri); $dir = $this->randomMachineName(); $edit = array(