You are here

public function JuiceboxFileCase::testFileNonImage in Juicebox HTML5 Responsive Image Galleries 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/JuiceboxFileCase.php \Drupal\Tests\juicebox\Functional\JuiceboxFileCase::testFileNonImage()

Test the non-image handling feature.

File

tests/src/Functional/JuiceboxFileCase.php, line 94

Class

JuiceboxFileCase
Tests general file and non-image handling.

Namespace

Drupal\Tests\juicebox\Functional

Code

public function testFileNonImage() {

  // Create a test node with a non-image file.
  $this
    ->createNodeWithFile('text');
  $node = $this->node;

  // Check the XML as anon user.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('juicebox/xml/field/node/' . $node
    ->id() . '/' . $this->instFieldName . '/full');

  // With the default settings we expect an "application-octet-stream.png"
  // value for both the image and the thumbnail.
  $this
    ->assertPattern('|imageURL=.*text.png.*thumbURL=.*text.png|', 'Non-image mimetype placeholder found for image and thumbnail.');

  // Change the file handling option to "skip".
  $this
    ->drupalLogin($this->webUser);
  $this
    ->drupalGet('admin/structure/types/manage/' . $this->instBundle . '/display');
  $this
    ->submitForm([], $this->instFieldName . '_settings_edit', 'entity-view-display-edit-form');
  $edit = [
    'fields[' . $this->instFieldName . '][settings_edit_form][settings][incompatible_file_action]' => 'skip',
  ];
  $this
    ->submitForm($edit, '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
    ->drupalLogout();
  $this
    ->drupalGet('juicebox/xml/field/node/' . $node
    ->id() . '/' . $this->instFieldName . '/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.
}