Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / file / tests / src / Kernel / SaveTest.php
index 87eb17b20d54fbc9cc1e8a0e310311f65714d318..193c5684ec1cbba785c09809c4ea7a5d45d29b46 100644 (file)
@@ -81,6 +81,22 @@ class SaveTest extends FileManagedUnitTestBase {
     $this->assertEqual(1, count($fids));
     $this->assertEqual([$uppercase_file->id() => $uppercase_file->id()], $fids);
 
+    // Save a file with zero bytes.
+    $file = File::create([
+      'uid' => 1,
+      'filename' => 'no-druplicon.txt',
+      'uri' => 'public://no-druplicon.txt',
+      'filemime' => 'text/plain',
+      'status' => FILE_STATUS_PERMANENT,
+    ]);
+
+    file_put_contents($file->getFileUri(), '');
+
+    // Save it, inserting a new record.
+    $file->save();
+
+    // Check the file size was set to zero.
+    $this->assertSame(0, $file->getSize());
   }
 
 }