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