function NavigationSafeBlockDefinitionTest::testNavigationSafeBlockDefinition

Tests logic to include blocks in Navigation Layout UI.

File

core/modules/navigation/tests/src/Functional/NavigationSafeBlockDefinitionTest.php, line 51

Class

NavigationSafeBlockDefinitionTest
Tests the definition of navigation safe blocks.

Namespace

Drupal\Tests\navigation\Functional

Code

public function testNavigationSafeBlockDefinition() : void {
    // Confirm that default blocks are available.
    $layout_url = '/admin/config/user-interface/navigation-block';
    $this->drupalGet($layout_url);
    $this->clickLink('Add block');
    $this->assertSession()
        ->linkExists('Administration');
    $this->assertSession()
        ->linkExists('Content');
    $this->assertSession()
        ->linkExists('Footer');
    $this->assertSession()
        ->linkExists('Navigation Shortcuts');
    $this->assertSession()
        ->linkExists('User');
    $this->assertSession()
        ->linkNotExists('Link');
    // Apply changes, clear cache and confirm that changes are applied.
    \Drupal::state()->set('navigation_safe_alter', TRUE);
    \Drupal::cache('discovery')->delete('block_plugins');
    $this->drupalGet($this->getUrl());
    $this->assertSession()
        ->linkExists('Administration');
    $this->assertSession()
        ->linkExists('Content');
    $this->assertSession()
        ->linkExists('Footer');
    $this->assertSession()
        ->linkExists('Link');
    $this->assertSession()
        ->linkNotExists('Navigation Shortcuts');
}

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