public function JuiceboxFieldFormatterCase::testFieldFormatter in Juicebox HTML5 Responsive Image Galleries 7.2
Test base logic for the Juicebox field formatter.
File
- tests/
JuiceboxFieldFormatterCase.test, line 41 - Test case for Juicebox field formatter.
Class
- JuiceboxFieldFormatterCase
- Class to define test case for Juicebox field formatter.
Code
public function testFieldFormatter() {
$instance = $this->instance;
$node = $this->node;
$xml_path = 'juicebox/xml/field/node/' . $node->nid . '/' . $instance['field_name'] . '/full';
// Get the urls to the test image and thumb derivative used by default. Note
// that the "large" style will be used for the article's field_image because
// that's was its formatter was set to before being flipped into a Juicebox
// display.
$items = field_get_items('node', $node, $instance['field_name']);
$item = reset($items);
$test_image_url = image_style_url('large', $item['uri']);
$test_thumb_url = image_style_url('juicebox_square_thumbnail', $item['uri']);
// Check for correct embed markup.
$this
->drupalGet('node/' . $node->nid);
$this
->assertRaw(trim(json_encode(array(
'configUrl' => url($xml_path),
)), '{}"'), 'Gallery setting found in Drupal.settings.');
$this
->assertRaw('id="field--node--' . $node->nid . '--' . str_replace('_', '-', $instance['field_name']) . '--full"', 'Embed code wrapper found.');
$this
->assertRaw('<li class="gallery_config', 'Example contextual link for gallery configuration found.');
$this
->assertRaw(check_plain($test_image_url), 'Test image found in embed code');
// Check for correct XML.
$this
->drupalGet($xml_path);
$this
->assertRaw('<?xml version="1.0" encoding="UTF-8"?>', 'Valid XML detected.');
$this
->assertRaw('imageURL="' . check_plain($test_image_url), 'Test image found in XML.');
$this
->assertRaw('thumbURL="' . check_plain($test_thumb_url), 'Test thumbnail found in XML.');
}