You are here

public function SettingsFormTest::testSettingsForm in Image Effects 8

Same name and namespace in other branches
  1. 8.3 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 32

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
    ->drupalPostForm(NULL, $edit, t('Save configuration'));

  // Check config changed.
  $this
    ->assertEqual('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
    ->drupalPostForm(NULL, $edit, t('Save configuration'));

  // Check config changed.
  $this
    ->assertEqual([
    '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
    ->drupalPostForm(NULL, $edit, t('Save configuration'));

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