You are here

public function SlickSettingsFormTest::testSlickSettingsForm in Slick Carousel 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/Form/SlickSettingsFormTest.php \Drupal\Tests\slick\Kernel\Form\SlickSettingsFormTest::testSlickSettingsForm()

Tests for \Drupal\slick_ui\Form\SlickSettingsForm.

@covers ::getFormId @covers ::getEditableConfigNames @covers ::buildForm @covers ::submitForm

File

tests/src/Kernel/Form/SlickSettingsFormTest.php, line 64

Class

SlickSettingsFormTest
Tests the Slick UI settings form.

Namespace

Drupal\Tests\slick\Kernel\Form

Code

public function testSlickSettingsForm() {

  // Emulate a form state of a submitted form.
  $form_state = (new FormState())
    ->setValues([
    'slick_css' => TRUE,
    'module_css' => TRUE,
  ]);
  $this
    ->assertInstanceOf(FormInterface::class, $this->slickSettingsForm);
  $this
    ->assertTrue($this->slickManager
    ->getConfigFactory()
    ->get('slick.settings')
    ->get('slick_css'));
  $id = $this->slickSettingsForm
    ->getFormId();
  $this
    ->assertEquals('slick_settings_form', $id);
  $method = new \ReflectionMethod(SlickSettingsForm::class, 'getEditableConfigNames');
  $method
    ->setAccessible(TRUE);
  $name = $method
    ->invoke($this->slickSettingsForm);
  $this
    ->assertEquals([
    'slick.settings',
  ], $name);
  $form = $this->slickSettingsForm
    ->buildForm([], $form_state);
  $this->slickSettingsForm
    ->submitForm($form, $form_state);
}