class BlockHookOperationTest
Same name and namespace in other branches
- 11.x core/modules/block/tests/src/Functional/BlockHookOperationTest.php \Drupal\Tests\block\Functional\BlockHookOperationTest
- 10 core/modules/block/tests/src/Functional/BlockHookOperationTest.php \Drupal\Tests\block\Functional\BlockHookOperationTest
- 8.9.x core/modules/block/tests/src/Functional/BlockHookOperationTest.php \Drupal\Tests\block\Functional\BlockHookOperationTest
Tests for Block module regarding hook_entity_operations_alter().
@group block
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \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\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\block\Functional\BlockHookOperationTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of BlockHookOperationTest
File
-
core/
modules/ block/ tests/ src/ Functional/ BlockHookOperationTest.php, line 12
Namespace
Drupal\Tests\block\FunctionalView source
class BlockHookOperationTest extends BrowserTestBase {
/**
* Modules to install.
*
* @var array
*/
protected static $modules = [
'block',
'entity_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$permissions = [
'administer blocks',
];
// Create and log in user.
$admin_user = $this->drupalCreateUser($permissions);
$this->drupalLogin($admin_user);
}
/**
* Tests the block list to see if the test_operation link is added.
*/
public function testBlockOperationAlter() {
// Add a test block, any block will do.
// Set the machine name so the test_operation link can be built later.
$block_id = mb_strtolower($this->randomMachineName(16));
$this->drupalPlaceBlock('system_powered_by_block', [
'id' => $block_id,
]);
// Get the Block listing.
$this->drupalGet('admin/structure/block');
$test_operation_link = 'admin/structure/block/manage/' . $block_id . '/test_operation';
// Test if the test_operation link is on the page.
$this->assertSession()
->linkByHrefExists($test_operation_link);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.