public function JuiceboxFileCase::testFileNonImage in Juicebox HTML5 Responsive Image Galleries 7.2
Test the non-image handling feature.
File
- tests/
JuiceboxFileCase.test, line 66 - Test case for Juicebox file handling.
Class
- JuiceboxFileCase
- Class to define test case for Juicebox file handling.
Code
public function testFileNonImage() {
// Setup a content type with image data. Use the "file" type and widget.
$instance = $this
->initFieldInstance('article', strtolower($this
->randomName(10)), 'file', 'file_generic');
$this
->activateJuiceboxFieldFormatter($instance);
// Create a new node and upload a non-image.
$test_image = current($this
->drupalGetTestFiles('text'));
$node = $this
->createNodeWithImage($instance, $test_image);
// Check the XML.
$this
->drupalGet('juicebox/xml/field/node/' . $node->nid . '/' . $instance['field_name'] . '/full');
// With the default settings we expect an "application-octet-stream.png"
// value for both the image and the thumbnail.
$this
->assertPattern('|imageURL=.*application-octet-stream.png.*thumbURL=.*application-octet-stream.png|', 'Non-image mimetype placeholder found for image and thumbnail.');
// Change the file handling option to "skip".
$this
->drupalPostAJAX('admin/structure/types/manage/' . $instance['bundle'] . '/display', array(), $instance['field_name'] . '_formatter_settings_edit', NULL, array(), array(), 'field-ui-display-overview-form');
$edit = array(
'fields[' . $instance['field_name'] . '][settings_edit_form][settings][incompatible_file_action]' => 'skip',
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertText(t('Your settings have been saved.'), 'Gallery configuration changes saved.');
// Re-check the XML. This time no image should appear at all.
$this
->drupalGet('juicebox/xml/field/node/' . $node->nid . '/' . $instance['field_name'] . '/full');
$this
->assertRaw('<?xml version="1.0" encoding="UTF-8"?>', 'Valid XML detected.');
$this
->assertNoRaw('<image', 'Non-image items was skipped.');
// @todo, Check other incompatible_file_action combinations.
}