$result =
$this->fileRepository->
move(clone $source,
$desired_filepath, FileSystemInterface::EXISTS_ERROR
);
// Check the return status and that the contents changed.
$this->
assertNotFalse($result, 'File moved successfully.'
);
$this->
assertFileDoesNotExist($source->
getFileUri());
$this->
assertEquals($contents,
file_get_contents($result->
getFileUri()), 'Contents of file correctly written.'
);
// Check that the correct hooks were called.
$this->
assertFileHooksCalled(['move', 'load', 'update'
]);
// Make sure we got the same file back.
$this->
assertEquals($source->
id(),
$result->
id(),
new FormattableMarkup("Source file id's' %fid is unchanged after move.",
['%fid' =>
$source->
id()]));
// Reload the file from the database and check that the changes were
// actually saved.
$loaded_file = File::
load($result->
id());
$this->
assertNotEmpty($loaded_file, 'File can be loaded from the database.'
);
$this->
assertFileUnchanged($result,
$loaded_file);
} /**
* Tests renaming when moving onto a file that already exists.
*
* @covers ::move
*/