// Upload a different file.
$edit =
[];
$edit['title[0][value]'
] = 'Scarlett Johansson';
$name = 'files[' .
$this->fieldName . '_0]';
$edit[$name] = \Drupal::
service('file_system'
)->
realpath($this->
drupalGetTestFiles('image'
)[1
]->uri
);
$this->
submitForm($edit, 'Save (this translation)'
);
$edit =
[$this->fieldName . '[0][alt]' => 'Scarlett Johansson image',
$this->fieldName . '[0][title]' => 'Scarlett Johansson image title'
];
$this->
submitForm($edit, 'Save (this translation)'
);
// This inspects the HTML after the post of the translation, the image
// should be displayed on the original node.
$this->
assertSession()->
responseContains('alt="Lost in translation image"'
);
$this->
assertSession()->
responseContains('title="Lost in translation image title"'
);
$second_fid =
$this->
getLastFileId();
// View the translated node.
$this->
drupalGet('fr/node/' .
$default_language_node->
id());
$this->
assertSession()->
responseContains('alt="Scarlett Johansson image"'
);
\Drupal::
entityTypeManager()->
getStorage('file'
)->
resetCache();
/** @var \Drupal\file\FileInterface $file */
// Ensure the file status of the first file permanent.