You are here

public function SelectorPluginTest::testImageSelector in Image Effects 8.2

Same name and namespace in other branches
  1. 8.3 tests/src/Functional/SelectorPluginTest.php \Drupal\Tests\image_effects\Functional\SelectorPluginTest::testImageSelector()
  2. 8 tests/src/Functional/SelectorPluginTest.php \Drupal\Tests\image_effects\Functional\SelectorPluginTest::testImageSelector()

Image selector test.

File

tests/src/Functional/SelectorPluginTest.php, line 29

Class

SelectorPluginTest
Selector plugins test.

Namespace

Drupal\Tests\image_effects\Functional

Code

public function testImageSelector() {
  $image_path = drupal_get_path('module', 'image_effects') . '/tests/images';
  $image_file = 'portrait-painting.jpe';

  // Test the Basic plugin.
  // Add an effect with the image selector.
  $effect = [
    'id' => 'image_effects_module_test_image_selection',
    'data' => [
      'image_uri' => $image_path . '/' . $image_file,
    ],
  ];
  $uuid = $this
    ->addEffectToTestStyle($effect);

  // Check that the full image URI is in the effect summary.
  $this
    ->assertText($image_path . '/' . $image_file);

  // Test the Dropdown plugin.
  // Remove the effect.
  $this
    ->removeEffectFromTestStyle($uuid);

  // Change the settings.
  $config = \Drupal::configFactory()
    ->getEditable('image_effects.settings');
  $config
    ->set('image_selector.plugin_id', 'dropdown')
    ->set('image_selector.plugin_settings.dropdown.path', $image_path)
    ->save();

  // Add an effect with the image selector.
  $effect = [
    'id' => 'image_effects_module_test_image_selection',
    'data' => [
      'image_uri' => $image_file,
    ],
  ];
  $this
    ->addEffectToTestStyle($effect);

  // Check that the full image URI is in the effect summary.
  $this
    ->assertText($image_path . '/' . $image_file);
}