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