You are here

public function SettingsFormTest::testSettingsForm in Image Effects 8.3

Same name and namespace in other branches
  1. 8 tests/src/Functional/SettingsFormTest.php \Drupal\Tests\image_effects\Functional\SettingsFormTest::testSettingsForm()
  2. 8.2 tests/src/Functional/SettingsFormTest.php \Drupal\Tests\image_effects\Functional\SettingsFormTest::testSettingsForm()

Settings form test.

File

tests/src/Functional/SettingsFormTest.php, line 46

Class

SettingsFormTest
Settings form test.

Namespace

Drupal\Tests\image_effects\Functional

Code

public function testSettingsForm() {
  $admin_path = '/admin/config/media/image_effects';

  // Get the settings form.
  $this
    ->drupalGet($admin_path);

  // Change the default color selector.
  $edit = [
    'settings[color_selector][plugin_id]' => 'farbtastic',
  ];
  $this
    ->submitForm($edit, 'Save configuration');

  // Check config changed.
  $this
    ->assertEquals('farbtastic', \Drupal::config('image_effects.settings')
    ->get('color_selector.plugin_id'));

  // Change the default image selector.
  $config = \Drupal::configFactory()
    ->getEditable('image_effects.settings');
  $config
    ->set('image_selector.plugin_id', 'dropdown')
    ->save();
  $this
    ->drupalGet($admin_path);
  $edit = [
    'settings[image_selector][plugin_settings][path]' => 'private://',
  ];
  $this
    ->submitForm($edit, 'Save configuration');

  // Check config changed.
  $this
    ->assertEquals([
    'path' => 'private://',
  ], \Drupal::config('image_effects.settings')
    ->get('image_selector.plugin_settings.dropdown'));

  // Change the default font selector.
  $config = \Drupal::configFactory()
    ->getEditable('image_effects.settings');
  $config
    ->set('font_selector.plugin_id', 'dropdown')
    ->save();
  $this
    ->drupalGet($admin_path);
  $edit = [
    'settings[font_selector][plugin_settings][path]' => 'public://',
  ];
  $this
    ->submitForm($edit, 'Save configuration');

  // Check config changed.
  $this
    ->assertEquals([
    'path' => 'public://',
  ], \Drupal::config('image_effects.settings')
    ->get('font_selector.plugin_settings.dropdown'));
}