diff --git a/core/modules/file/tests/src/Kernel/SaveTest.php b/core/modules/file/tests/src/Kernel/SaveTest.php index 82113681adedd7df8c290f88818bbc842ec0548b..6de2071e05f20ea3fab91ac80a94c77194867071 100644 --- a/core/modules/file/tests/src/Kernel/SaveTest.php +++ b/core/modules/file/tests/src/Kernel/SaveTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\file\Kernel; use Drupal\file\Entity\File; +use Drupal\Tests\user\Traits\UserCreationTrait; /** * File saving tests. @@ -13,18 +14,13 @@ */ class SaveTest extends FileManagedUnitTestBase { - /** - * {@inheritdoc} - * - * @todo Remove and fix test to not rely on super user. - * @see https://www.drupal.org/project/drupal/issues/3437620 - */ - protected bool $usesSuperUserAccessPolicy = TRUE; + use UserCreationTrait; public function testFileSave(): void { + $account = $this->createUser(); // Create a new file entity. $file = File::create([ - 'uid' => 1, + 'uid' => $account->id(), 'filename' => 'druplicon.txt', 'uri' => 'public://druplicon.txt', 'filemime' => 'text/plain', @@ -67,7 +63,7 @@ public function testFileSave(): void { // Try to insert a second file with the same name apart from case insensitivity // to ensure the 'uri' index allows for filenames with different cases. $uppercase_values = [ - 'uid' => 1, + 'uid' => $account->id(), 'filename' => 'DRUPLICON.txt', 'uri' => 'public://DRUPLICON.txt', 'filemime' => 'text/plain', @@ -96,7 +92,7 @@ public function testFileSave(): void { // Save a file with zero bytes. $file = File::create([ - 'uid' => 1, + 'uid' => $account->id(), 'filename' => 'no-druplicon.txt', 'uri' => 'public://no-druplicon.txt', 'filemime' => 'text/plain',