BlockHookOperationTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Drupal\Tests\block\Functional;
  3. use Drupal\Tests\BrowserTestBase;
  4. /**
  5. * Tests for Block module regarding hook_entity_operations_alter().
  6. *
  7. * @group block
  8. */
  9. class BlockHookOperationTest extends BrowserTestBase {
  10. /**
  11. * Modules to install.
  12. *
  13. * @var array
  14. */
  15. public static $modules = ['block', 'entity_test'];
  16. protected function setUp() {
  17. parent::setUp();
  18. $permissions = [
  19. 'administer blocks',
  20. ];
  21. // Create and log in user.
  22. $admin_user = $this->drupalCreateUser($permissions);
  23. $this->drupalLogin($admin_user);
  24. }
  25. /**
  26. * Tests the block list to see if the test_operation link is added.
  27. */
  28. public function testBlockOperationAlter() {
  29. // Add a test block, any block will do.
  30. // Set the machine name so the test_operation link can be built later.
  31. $block_id = mb_strtolower($this->randomMachineName(16));
  32. $this->drupalPlaceBlock('system_powered_by_block', ['id' => $block_id]);
  33. // Get the Block listing.
  34. $this->drupalGet('admin/structure/block');
  35. $test_operation_link = 'admin/structure/block/manage/' . $block_id . '/test_operation';
  36. // Test if the test_operation link is on the page.
  37. $this->assertLinkByHref($test_operation_link);
  38. }
  39. }