class BlockContextualLinksTest
Same name and namespace in other branches
- 11.x core/modules/block/tests/src/FunctionalJavascript/BlockContextualLinksTest.php \Drupal\Tests\block\FunctionalJavascript\BlockContextualLinksTest
- 10 core/modules/block/tests/src/FunctionalJavascript/BlockContextualLinksTest.php \Drupal\Tests\block\FunctionalJavascript\BlockContextualLinksTest
- 9 core/modules/block/tests/src/FunctionalJavascript/BlockContextualLinksTest.php \Drupal\Tests\block\FunctionalJavascript\BlockContextualLinksTest
Tests the contextual links added while rendering the block.
Attributes
#[Group('block')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\block\FunctionalJavascript\BlockContextualLinksTest extends \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of BlockContextualLinksTest
File
-
core/
modules/ block/ tests/ src/ FunctionalJavascript/ BlockContextualLinksTest.php, line 14
Namespace
Drupal\Tests\block\FunctionalJavascriptView source
class BlockContextualLinksTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'user',
'block',
'contextual',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Block id of the block.
*
* @var string
*/
protected $blockId;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->drupalLogin($this->drupalCreateUser([
'administer blocks',
'access administration pages',
'access contextual links',
]));
$this->blockId = $this->defaultTheme . '_powered';
$this->placeBlock('system_powered_by_block', [
'id' => $this->blockId,
'region' => 'content',
]);
}
/**
* Test that remove/configure contextual links are present in the block.
*/
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.