function ViewsBlockTest::testOperationLinks

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

Tests the editing links for ViewsBlockBase.

File

core/modules/views_ui/tests/src/Kernel/ViewsBlockTest.php, line 52

Class

ViewsBlockTest
Tests ViewsBlock.

Namespace

Drupal\Tests\views_ui\Kernel

Code

public function testOperationLinks() : void {
    $this->setUpCurrentUser([
        'uid' => 0,
    ]);
    $block = Block::create([
        'plugin' => 'views_block:test_view_block-block_1',
        'region' => 'content',
        'id' => 'machine_name',
        'theme' => 'stark',
    ]);
    // The anonymous user doesn't have the "administer block" permission.
    $this->assertEmpty(views_ui_entity_operation($block));
    $this->setUpCurrentUser([
        'uid' => 1,
    ], [
        'administer views',
    ]);
    // The admin user does have the "administer block" permission.
    $this->assertEquals([
        'view-edit' => [
            'title' => 'Edit view',
            'url' => Url::fromRoute('entity.view.edit_display_form', [
                'view' => 'test_view_block',
                'display_id' => 'block_1',
            ]),
            'weight' => 50,
        ],
    ], views_ui_entity_operation($block));
}

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