function MenuBlockTest::testOperationLinks

Same name in other branches
  1. 11.x core/modules/menu_ui/tests/src/Kernel/MenuBlockTest.php \Drupal\Tests\menu_ui\Kernel\MenuBlockTest::testOperationLinks()

Tests the editing links for SystemMenuBlock.

File

core/modules/menu_ui/tests/src/Kernel/MenuBlockTest.php, line 64

Class

MenuBlockTest
Tests SystemMenuBlock.

Namespace

Drupal\Tests\menu_ui\Kernel

Code

public function testOperationLinks() : void {
    $block = Block::create([
        'plugin' => 'system_menu_block:' . $this->menu
            ->id(),
        'region' => 'footer',
        'id' => 'machine_name',
        'theme' => 'stark',
    ]);
    // Test when user does have "administer menu" permission.
    $this->assertEquals([
        'menu-edit' => [
            'title' => 'Edit menu',
            'url' => $this->menu
                ->toUrl('edit-form'),
            'weight' => 50,
        ],
    ], menu_ui_entity_operation($block));
    $this->setUpCurrentUser();
    // Test when user doesn't have "administer menu" permission.
    $this->assertEmpty(menu_ui_entity_operation($block));
}

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