Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / block / tests / src / Unit / Menu / BlockLocalTasksTest.php
1 <?php
2
3 namespace Drupal\Tests\block\Unit\Menu;
4
5 use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
6 use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8 /**
9  * Tests block local tasks.
10  *
11  * @group block
12  */
13 class BlockLocalTasksTest extends LocalTaskIntegrationTestBase {
14
15   protected function setUp() {
16     $this->directoryList = ['block' => 'core/modules/block'];
17     parent::setUp();
18
19     $config_factory = $this->getConfigFactoryStub([
20       'system.theme' => ['default' => 'test_c'],
21     ]);
22
23     $themes = [];
24     $themes['test_a'] = (object) [
25       'status' => 1,
26       'info' => [
27         'name' => 'test_a',
28         'hidden' => TRUE,
29       ],
30     ];
31     $themes['test_b'] = (object) [
32       'status' => 1,
33       'info' => [
34         'name' => 'test_b',
35       ],
36     ];
37     $themes['test_c'] = (object) [
38       'status' => 1,
39       'info' => [
40         'name' => 'test_c',
41       ],
42     ];
43     $theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
44     $theme_handler->expects($this->any())
45       ->method('listInfo')
46       ->will($this->returnValue($themes));
47     $theme_handler->expects($this->any())
48       ->method('hasUi')
49       ->willReturnMap([
50         ['test_a', FALSE],
51         ['test_b', TRUE],
52         ['test_c', TRUE],
53       ]);
54
55     $container = new ContainerBuilder();
56     $container->set('config.factory', $config_factory);
57     $container->set('theme_handler', $theme_handler);
58     $container->set('app.root', $this->root);
59     \Drupal::setContainer($container);
60   }
61
62   /**
63    * Tests the admin edit local task.
64    */
65   public function testBlockAdminLocalTasks() {
66     $this->assertLocalTasks('entity.block.edit_form', [['entity.block.edit_form']]);
67   }
68
69   /**
70    * Tests the block admin display local tasks.
71    *
72    * @dataProvider providerTestBlockAdminDisplay
73    */
74   public function testBlockAdminDisplay($route, $expected) {
75     $this->assertLocalTasks($route, $expected);
76   }
77
78   /**
79    * Provides a list of routes to test.
80    */
81   public function providerTestBlockAdminDisplay() {
82     return [
83       ['block.admin_display', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]],
84       ['block.admin_display_theme', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]],
85     ];
86   }
87
88 }