You are here

public function RateWidgetSettingsTest::testSettingsFormDisableLog in Rate 8.2

Tests the disable log settings.

File

tests/src/Functional/RateWidgetSettingsTest.php, line 63

Class

RateWidgetSettingsTest
Tests the SettingsForm form.

Namespace

Drupal\Tests\rate\Functional

Code

public function testSettingsFormDisableLog() {
  $form_state = (new FormState())
    ->setValues([
    'disable_log' => FALSE,
  ]);
  $this->formBuilder
    ->submitForm(RateSettingsForm::class, $form_state);
  $this->settingsConfig = $this
    ->config('rate.settings');
  $this
    ->assertCount(0, $form_state
    ->getErrors());
  $this
    ->assertEmpty($this->settingsConfig
    ->get('disable_log'));
  $this
    ->drupalGet('node/1');
  $form_state = (new FormState())
    ->setValues([
    'disable_log' => TRUE,
  ]);
  $this->formBuilder
    ->submitForm(RateSettingsForm::class, $form_state);
  $this->settingsConfig = $this
    ->config('rate.settings');
  $this
    ->assertCount(0, $form_state
    ->getErrors());
  $this
    ->assertTrue($this->settingsConfig
    ->get('disable_log'));
  $this
    ->drupalGet('node/2');
}