// Create a default language node.
$default_language_node =
$this->
drupalCreateNode(['type' => 'basicpage', 'title' => 'Lost in translation'
]);
// Edit the node to upload a file.
$edit =
[];
$name = 'files[' .
$this->fieldName . '_0]';
$edit[$name] = \Drupal::
service('file_system'
)->
realpath($this->
drupalGetTestFiles('image'
)[0
]->uri
);
$this->
drupalGet('node/' .
$default_language_node->
id() . '/edit'
);
$this->
submitForm($edit, 'Save'
);
$edit =
[$this->fieldName . '[0][alt]' => 'Lost in translation image',
$this->fieldName . '[0][title]' => 'Lost in translation image title'
];
$this->
submitForm($edit, 'Save'
);
$first_fid =
$this->
getLastFileId();
// Translate the node into French: remove the existing file.
$this->
drupalGet('node/' .
$default_language_node->
id() . '/translations/add/en/fr'
);
$this->
submitForm([], 'Remove'
);
// 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)'
);