function BlockContextualLinksTest::testBlockContextualRemoveLinks

Same name in other branches
  1. 9 core/modules/block/tests/src/FunctionalJavascript/BlockContextualLinksTest.php \Drupal\Tests\block\FunctionalJavascript\BlockContextualLinksTest::testBlockContextualRemoveLinks()
  2. 10 core/modules/block/tests/src/FunctionalJavascript/BlockContextualLinksTest.php \Drupal\Tests\block\FunctionalJavascript\BlockContextualLinksTest::testBlockContextualRemoveLinks()

Test that remove/configure contextual links are present in the block.

File

core/modules/block/tests/src/FunctionalJavascript/BlockContextualLinksTest.php, line 53

Class

BlockContextualLinksTest
Tests the contextual links added while rendering the block.

Namespace

Drupal\Tests\block\FunctionalJavascript

Code

public function testBlockContextualRemoveLinks() : void {
    $this->drupalGet('<front>');
    $contextual_id = "[data-contextual-id^='block:block={$this->blockId}:langcode=en']";
    $this->assertSession()
        ->waitForElement('css', "{$contextual_id} .contextual-links");
    $expected_configure_block_link = base_path() . 'admin/structure/block/manage/' . $this->blockId;
    $actual_configure_block_link = parse_url($this->getSession()
        ->getPage()
        ->findLink('Configure block')
        ->getAttribute('href'));
    $this->assertEquals($expected_configure_block_link, $actual_configure_block_link['path']);
    $expected_remove_block_link = base_path() . 'admin/structure/block/manage/' . $this->blockId . '/delete';
    $actual_remove_block_link = parse_url($this->getSession()
        ->getPage()
        ->findLink('Remove block')
        ->getAttribute('href'));
    $this->assertEquals($expected_remove_block_link, $actual_remove_block_link['path']);
}

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