function BookSettingsFormTest::testConfigValuesSavedCorrectly

Same name and namespace in other branches
  1. 10 core/modules/book/tests/src/Kernel/BookSettingsFormTest.php \Drupal\Tests\book\Kernel\BookSettingsFormTest::testConfigValuesSavedCorrectly()

Tests that submitted values are processed and saved correctly.

File

core/modules/book/tests/src/Kernel/BookSettingsFormTest.php, line 43

Class

BookSettingsFormTest
@covers <a href="/api/drupal/core%21modules%21book%21src%21Form%21BookSettingsForm.php/class/BookSettingsForm/11.x" title="Configure book settings for this site." class="local">\Drupal\book\Form\BookSettingsForm</a> @group book

Namespace

Drupal\Tests\book\Kernel

Code

public function testConfigValuesSavedCorrectly() : void {
    $form_state = new FormState();
    $form_state->setValues([
        'book_allowed_types' => [
            'page',
            'chapter',
            '',
        ],
        'book_child_type' => 'page',
    ]);
    $this->container
        ->get('form_builder')
        ->submitForm(BookSettingsForm::class, $form_state);
    $config = $this->config('book.settings');
    $this->assertSame([
        'chapter',
        'page',
    ], $config->get('allowed_types'));
    $this->assertSame('page', $config->get('child_type'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.