function MenuLinksetSettingsFormTest::testMenuLinksetSettingsForm

Same name in other branches
  1. 10 core/modules/system/tests/src/Functional/Form/MenuLinksetSettingsFormTest.php \Drupal\Tests\system\Functional\Form\MenuLinksetSettingsFormTest::testMenuLinksetSettingsForm()

Tests the menu_linkset_settings form.

File

core/modules/system/tests/src/Functional/Form/MenuLinksetSettingsFormTest.php, line 41

Class

MenuLinksetSettingsFormTest
Tests the menu_linkset_settings form.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testMenuLinksetSettingsForm() : void {
    // Users without the appropriate permissions should not be able to access.
    $this->drupalGet('admin/config/services/linkset');
    $this->assertSession()
        ->pageTextContains('Access denied');
    // Users with permission should be able to access the form.
    $permissions = [
        'administer site configuration',
    ];
    $this->adminAccount = $this->setUpCurrentUser([
        'name' => 'system_admin',
        'pass' => 'adminPass',
    ], $permissions);
    $this->drupalLogin($this->adminAccount);
    $this->drupalGet('admin/config/services/linkset');
    $this->assertSession()
        ->elementExists('css', '#edit-actions > input.button--primary');
    // Confirm endpoint can be enabled.
    $this->assertSession()
        ->fieldExists('edit-enable-endpoint')
        ->check();
    $this->submitForm([], 'Save configuration');
    $this->assertSession()
        ->pageTextContains('The configuration options have been saved.');
    $this->assertSession()
        ->fieldExists('edit-enable-endpoint')
        ->isChecked();
    $is_endpoint_enabled = $this->config('system.feature_flags')
        ->get('linkset_endpoint');
    $this->assertTrue($is_endpoint_enabled, 'Endpoint is enabled.');
    // Confirm endpoint can be disabled.
    $this->assertSession()
        ->fieldExists('edit-enable-endpoint')
        ->uncheck();
    $this->submitForm([], 'Save configuration');
    $this->assertSession()
        ->pageTextContains('The configuration options have been saved.');
    $is_endpoint_enabled = $this->config('system.feature_flags')
        ->get('linkset_endpoint');
    $this->assertFalse($is_endpoint_enabled, 'Endpoint is disabled.');
}

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