function QuickEditIntegrationTest::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/ settings_tray/ tests/ src/ FunctionalJavascript/ QuickEditIntegrationTest.php, line 136
Class
- QuickEditIntegrationTest
- Test Settings Tray and Quick Edit modules integration.
Namespace
Drupal\Tests\settings_tray\FunctionalJavascriptCode
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->assertTrue(strstr($href, "/admin/structure/block/manage/custom/settings-tray?destination={$destination}") !== FALSE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.