Error message
You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).function ImageFieldDisplayTestCase::testMissingImageFieldDisplay
Tests the display of image field with the missing FID.
File
-
modules/
image/ image.test, line 1217
Class
- ImageFieldDisplayTestCase
- Test class to check that formatters and display settings are working.
Code
function testMissingImageFieldDisplay() {
$field_name = strtolower ($this->randomName ());
$type_name = 'article';
$field_settings = array(
'display_field' => '1',
'display_default' => '1',
);
$instance_settings = array(
'description_field' => '1',
);
$widget_settings = array();
$this->createImageField ($field_name, $type_name, $field_settings, $instance_settings, $widget_settings);
$images = $this->drupalGetTestFiles ('image');
// Create a new node with the uploaded file.
$nid = $this->uploadNodeImage ($images[1], $field_name, 'article');
// Delete uploaded file from file_managed table.
$max_fid_after = db_query ('SELECT MAX(fid) AS fid FROM {file_managed}')->fetchField ();
$uploaded_file = file_load ($max_fid_after);
file_delete ($uploaded_file, TRUE);
// Clear field cache.
field_cache_clear ();
// Check the node detail if the file is loaded.
$this->drupalGet ('node/' . $nid);
$this->assertResponse (200);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.