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