As I mentioned in my previous question I'm attempting to write tests for a patch that will, ideally, trigger the creation of a redirect if the URI of a file changes.
My patch uses hook_file_update() which is called whenever file_save() runs.
Currently this chunk of code:
// Move file to new URI $new_uri = 'public://qwerty.png'; file_save($test_file); $test_file->uri = $new_uri; file_save($test_file);
This calls my hook and creates the redirect, but the redirect fails because
drupalGet($new_url) returns a 404.
file_save() returns the error,
filesize() [function.filesize]: stat failed for public://qwerty.png.
file_save() on URIs that linked to existing files, which gives an error, I've tried it on not-yet-extant URIs (as above), which gives an error, and I've tried
file_move(), which doesn't call
How can I programmatically change the URI of a file and trigger
hook_file_update() inside a test?