You are here

public function JuiceboxConfCase::testConfigPro in Juicebox HTML5 Responsive Image Galleries 8.2

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

Test common Pro configuration logic for a Juicebox formatter.

File

tests/src/Functional/JuiceboxConfCase.php, line 100

Class

JuiceboxConfCase
Tests gallery-specific configuration logic for Juicebox galleries.

Namespace

Drupal\Tests\juicebox\Functional

Code

public function testConfigPro() {
  $node = $this->node;

  // Do a set of control requests as an anon user that will also prime any
  // caches.
  $this
    ->drupalGet('node/' . $node
    ->id());
  $this
    ->assertResponse(200, 'Control request of test node was successful.');
  $this
    ->drupalGet('juicebox/xml/field/node/' . $node
    ->id() . '/' . $this->instFieldName . '/full');
  $this
    ->assertResponse(200, 'Control request of XML was successful.');

  // Set new manual options and also add a manual customization that's
  // intended to override a custom Lite option.
  $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][jlib_showExpandButton]' => FALSE,
    'fields[' . $this->instFieldName . '][settings_edit_form][settings][manual_config]' => "sHoWoPeNbUtToN=\"FALSE\"\nshowexpandbutton=\"TRUE\"\ngallerywidth=\"50%\"\nmyCustomSetting=\"boomsauce\"",
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertText(t('Your settings have been saved.'), 'Gallery configuration changes saved.');
  $this
    ->drupalLogout();

  // Check for correct embed markup.
  $this
    ->drupalGet('node/' . $node
    ->id());
  $this
    ->assertRaw(trim(json_encode([
    'gallerywidth' => '50%',
    'galleryheight' => '100%',
    'backgroundcolor' => '#222222',
  ]), '{}'), 'Expected custom configuration options found in Drupal.settings.');

  // Check for correct XML.
  $this
    ->drupalGet('juicebox/xml/field/node/' . $node
    ->id() . '/' . $this->instFieldName . '/full');
  $this
    ->assertRaw('<juicebox gallerywidth="50%" galleryheight="100%" backgroundcolor="#222222" textcolor="rgba(255,255,255,1)" thumbframecolor="rgba(255,255,255,.5)" showopenbutton="FALSE" showexpandbutton="TRUE" showthumbsbutton="TRUE" usethumbdots="FALSE" usefullscreenexpand="FALSE" mycustomsetting="boomsauce">', 'Expected custom Pro configuration options set in XML.');
}