Verified Commit dd994edd authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3439836 by pooja_sharma, thebumik, FeyP, vensires, smustgrave,...

Issue #3439836 by pooja_sharma, thebumik, FeyP, vensires, smustgrave, kim.pepper, quietone: Fix File tests that rely on UID1's super user behavior

(cherry picked from commit 35dbb2d4)
parent 99b53d92
Loading
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -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',