From e41b685b4a5bdb0200bbbe84d789ae0ce956985f Mon Sep 17 00:00:00 2001
From: catch <6915-catch@users.noreply.drupalcode.org>
Date: Sat, 10 Aug 2024 11:44:39 +0900
Subject: [PATCH] Issue #3385846 by pooja_sharma, joachim:
 FileOnTranslatedEntityTest should use API to set up language

(cherry picked from commit b6c3c60a4e77fbd91210943ec17782a6b263038c)
---
 .../Functional/FileOnTranslatedEntityTest.php    | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
index bc97169642b3..ac115f2385d2 100644
--- a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
+++ b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
@@ -5,6 +5,7 @@
 namespace Drupal\Tests\file\Functional;
 
 use Drupal\file\Entity\File;
+use Drupal\node\Entity\Node;
 use Drupal\Tests\content_translation\Traits\ContentTranslationTestTrait;
 
 // cspell:ignore Scarlett Johansson
@@ -217,13 +218,6 @@ public function testFileUsage(): void {
     /** @var \Drupal\file\FileUsage\FileUsageInterface $file_usage */
     $file_usage = \Drupal::service('file.usage');
 
-    // Enable language selector on the page edit form.
-    $edit = [
-      'language_configuration[language_alterable]' => 1,
-    ];
-    $this->drupalGet('admin/structure/types/manage/page');
-    $this->submitForm($edit, 'Save');
-
     // Create a node and upload a file.
     $node = $this->drupalCreateNode(['type' => 'page']);
     $edit = [
@@ -238,11 +232,9 @@ public function testFileUsage(): void {
 
     // Check if the file usage is tracked correctly when changing the original
     // language of an entity.
-    $edit = [
-      'langcode[0][value]' => 'fr',
-    ];
-    $this->drupalGet('node/' . $node->id() . '/edit');
-    $this->submitForm($edit, 'Save');
+    $node = Node::load($node->id());
+    $node->set('langcode', 'fr');
+    $node->save();
     $this->assertEquals($file_usage->listUsage($file), ['file' => ['node' => [$node->id() => '1']]]);
   }
 
-- 
GitLab