public function JuiceboxConfCase::testConfigAdvanced in Juicebox HTML5 Responsive Image Galleries 8.2
Same name and namespace in other branches
- 8.3 tests/src/Functional/JuiceboxConfCase.php \Drupal\Tests\juicebox\Functional\JuiceboxConfCase::testConfigAdvanced()
Test common Advanced configuration logic for a Juicebox formatter.
File
- tests/
src/ Functional/ JuiceboxConfCase.php, line 135
Class
- JuiceboxConfCase
- Tests gallery-specific configuration logic for Juicebox galleries.
Namespace
Drupal\Tests\juicebox\FunctionalCode
public function testConfigAdvanced() {
$node = $this->node;
// Get the urls to the main image with and without "large" styling.
$uri = File::load($node->{$this->instFieldName}[0]->target_id)
->getFileUri();
$test_image_url = file_create_url($uri);
$test_image_url_formatted = entity_load('image_style', 'juicebox_medium')
->buildUrl($uri);
// Check control case without custom configuration.
$this
->drupalGet('juicebox/xml/field/node/' . $node
->id() . '/' . $this->instFieldName . '/full');
$this
->assertRaw('linkTarget="_blank"', 'Default linkTarget setting found.');
$this
->assertRaw('linkURL="' . $test_image_url, 'Test unstyled image found in XML');
// Set new advanced options.
$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][image_style]' => 'juicebox_medium',
'fields[' . $this->instFieldName . '][settings_edit_form][settings][linkurl_source]' => 'image_styled',
'fields[' . $this->instFieldName . '][settings_edit_form][settings][linkurl_target]' => '_self',
'fields[' . $this->instFieldName . '][settings_edit_form][settings][custom_parent_classes]' => 'my-custom-wrapper',
];
$this
->submitForm($edit, 'Save');
$this
->assertText(t('Your settings have been saved.'), 'Gallery configuration changes saved.');
$this
->drupalLogout();
// Check case with custom configuration.
$this
->drupalGet('juicebox/xml/field/node/' . $node
->id() . '/' . $this->instFieldName . '/full');
$this
->assertRaw('linkTarget="_self"', 'Updated linkTarget setting found in XML.');
$this
->assertRaw('linkURL="' . Html::escape($test_image_url_formatted), 'Test styled image found in XML for linkURL.');
// Also check for custom class in embed code.
$this
->drupalGet('node/' . $node
->id());
$this
->assertRaw('class="juicebox-parent my-custom-wrapper"', 'Custom class found in embed code.');
}