function SettingsTrayIntegrationTest::testCustomBlockLinks

Tests that contextual links in custom blocks are changed.

"Quick edit" is quickedit.module link. "Quick edit settings" is settings_tray.module link.

File

core/modules/quickedit/tests/src/FunctionalJavascript/SettingsTrayIntegrationTest.php, line 148

Class

SettingsTrayIntegrationTest
Test Settings Tray and Quick Edit modules integration.

Namespace

Drupal\Tests\quickedit\FunctionalJavascript

Code

public function testCustomBlockLinks() {
    $this->createBlockContentType('basic', TRUE);
    $block_content = $this->createBlockContent('Custom Block', 'basic', TRUE);
    $this->placeBlock('block_content:' . $block_content->uuid(), [
        'id' => 'custom',
    ]);
    $this->drupalGet('user');
    $page = $this->getSession()
        ->getPage();
    $this->toggleContextualTriggerVisibility('#block-custom');
    $page->find('css', '#block-custom .contextual button')
        ->press();
    $links = $page->findAll('css', "#block-custom .contextual-links li a");
    $link_labels = [];
    
    /** @var \Behat\Mink\Element\NodeElement $link */
    foreach ($links as $link) {
        $link_labels[$link->getAttribute('href')] = $link->getText();
    }
    $href = array_search('Quick edit', $link_labels);
    $this->assertEquals('', $href);
    $href = array_search('Quick edit settings', $link_labels);
    $destination = (string) $this->loggedInUser
        ->toUrl()
        ->toString();
    $this->assertStringContainsString("/admin/structure/block/manage/custom/settings-tray?destination={$destination}", $href);
}

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