You are here

public function JuiceboxViewsCase::testViewsFile in Juicebox HTML5 Responsive Image Galleries 7.2

Test using pre-packaged Juicebox view that lists files instead of content.

File

tests/JuiceboxViewsCase.test, line 101
Test case for integration with File Entity module.

Class

JuiceboxViewsCase
Class to define test case for integration with File Entity module.

Code

public function testViewsFile() {
  $xml_path = 'juicebox/xml/viewsstyle/juicebox_views_file_test/page';

  // Get the urls to the test image and thumb derivative used by default.
  $items = field_get_items('node', $this->node, $this->instance['field_name']);
  $item = reset($items);
  $test_image_url = image_style_url('juicebox_medium', $item['uri']);
  $test_thumb_url = image_style_url('juicebox_square_thumbnail', $item['uri']);

  // Check for correct embed markup.
  $this
    ->drupalGet('juicebox-views-file-test');
  $this
    ->assertRaw(trim(json_encode(array(
    'configUrl' => url($xml_path),
  )), '{}"'), 'Gallery setting found in Drupal.settings.');
  $this
    ->assertRaw('id="viewsstyle--juicebox-views-file-test--page"', 'Embed code wrapper 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.');

  // The node's title field is setup to be the filename.
  $this
    ->assertRaw('<title><![CDATA[' . $item['filename'] . ']]></title>', 'Image title text found in XML.');
}