$this->
assertEquals($generate_url,
$generate_url_from_relative_path);
$this->
config('system.file'
)->
set('default_scheme', 'temporary'
)->
save();
// Fetch the URL that generates the file.
$this->
drupalGet($generate_url);
$this->
assertSession()->
statusCodeEquals(200
);
$this->
assertFileExists($generated_uri);
// assertRaw can't be used with string containing non UTF-8 chars.
$this->
assertNotEmpty(file_get_contents($generated_uri), 'URL returns expected file.'
);
$image =
$this->container->
get('image.factory'
)->
get($generated_uri);
$this->
assertSession()->
responseHeaderEquals('Content-Type',
$image->
getMimeType());
$this->
assertSession()->
responseHeaderEquals('Content-Length',
(string) $image->
getFileSize());
// Check that we did not download the original file.
$original_image =
$this->container->
get('image.factory'
) ->
get($original_uri);
$this->
assertSession()->
responseHeaderNotEquals('Content-Length',
(string) $original_image->
getFileSize());
if ($scheme == 'private'
) { $this->
assertSession()->
responseHeaderEquals('Expires', 'Sun, 19 Nov 1978 05:00:00 GMT'
);
// Check that Cache-Control header contains 'no-cache' to prevent caching.
$this->
assertSession()->
responseHeaderContains('Cache-Control', 'no-cache'
);
$this->
assertSession()->
responseHeaderEquals('X-Image-Owned-By', 'image_module_test'
);