Commit e41b685b authored by catch's avatar catch
Browse files

Issue #3385846 by pooja_sharma, joachim: FileOnTranslatedEntityTest should use...

Issue #3385846 by pooja_sharma, joachim: FileOnTranslatedEntityTest should use API to set up language

(cherry picked from commit b6c3c60a)
parent 557d779f
Loading
Loading
Loading
Loading
Loading
+4 −12
Original line number Diff line number Diff line
@@ -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']]]);
  }