From 337b3709b108d4ce40c9a76fdfc39ae9b69dd43c Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Thu, 25 Jul 2013 16:05:21 +0200 Subject: [PATCH] Issue #2046809 by larowlan, quicksketch: Fixed UUIDs not added when file uploaded using managed_file() FAPI element. --- .../lib/Drupal/file/FileStorageController.php | 2 +- .../file/lib/Drupal/file/Tests/LoadTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/core/modules/file/lib/Drupal/file/FileStorageController.php b/core/modules/file/lib/Drupal/file/FileStorageController.php index 10ba8d37bdc1..f3167a6b479f 100644 --- a/core/modules/file/lib/Drupal/file/FileStorageController.php +++ b/core/modules/file/lib/Drupal/file/FileStorageController.php @@ -52,7 +52,7 @@ class FileStorageController extends DatabaseStorageControllerNG implements FileS $properties['uuid'] = array( 'label' => t('UUID'), 'description' => t('The file UUID.'), - 'type' => 'string_field', + 'type' => 'uuid_field', 'read-only' => TRUE, ); $properties['langcode'] = array( diff --git a/core/modules/file/lib/Drupal/file/Tests/LoadTest.php b/core/modules/file/lib/Drupal/file/Tests/LoadTest.php index 57013defdcc1..0199ea26b604 100644 --- a/core/modules/file/lib/Drupal/file/Tests/LoadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/LoadTest.php @@ -88,4 +88,23 @@ class LoadTest extends FileManagedTestBase { $this->assertTrue($by_fid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.'); $this->assertEqual($by_fid_file->getFileUri(), $file->getFileUri(), 'Loading by fid got the correct filepath.', 'File'); } + + /** + * Loads a single file and ensure that the correct values are returned. + */ + public function testUuidValues() { + // Create a new file entity from scratch so we know the values. + $file = $this->createFile('druplicon.txt', NULL, 'public'); + $file->save(); + file_test_reset(); + + $by_uuid_file = entity_load_by_uuid('file', $file->uuid()); + $this->assertFileHookCalled('load'); + $this->assertTrue(is_object($by_uuid_file), 'entity_load_by_uuid() returned a file object.'); + if (is_object($by_uuid_file)) { + $this->assertEqual($by_uuid_file->id(), $file->id(), 'Loading by UUID got the same fid.', 'File'); + $this->assertTrue($by_uuid_file->file_test['loaded'], 'file_test_file_load() was able to modify the file during load.'); + } + } + }