b9986c9b4c3f6826609113a1a349fa5cde96d7f8
[yaffs-website] / web / core / modules / user / tests / src / Unit / Menu / UserLocalTasksTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Unit\Menu;
4
5 use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
6
7 /**
8  * Tests user local tasks.
9  *
10  * @group user
11  */
12 class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
13
14   protected function setUp() {
15     $this->directoryList = ['user' => 'core/modules/user'];
16     parent::setUp();
17   }
18
19   /**
20    * Tests local task existence.
21    *
22    * @dataProvider getUserAdminRoutes
23    */
24   public function testUserAdminLocalTasks($route, $expected) {
25     $this->assertLocalTasks($route, $expected);
26   }
27
28   /**
29    * Provides a list of routes to test.
30    */
31   public function getUserAdminRoutes() {
32     return [
33       ['entity.user.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection']]],
34       ['user.admin_permissions', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection']]],
35       ['entity.user_role.collection', [['entity.user.collection', 'user.admin_permissions', 'entity.user_role.collection']]],
36       ['entity.user.admin_form', [['user.account_settings_tab']]],
37     ];
38   }
39
40   /**
41    * Checks user listing local tasks.
42    *
43    * @dataProvider getUserLoginRoutes
44    */
45   public function testUserLoginLocalTasks($route) {
46     $tasks = [
47       0 => ['user.register', 'user.pass', 'user.login'],
48     ];
49     $this->assertLocalTasks($route, $tasks);
50   }
51
52   /**
53    * Provides a list of routes to test.
54    */
55   public function getUserLoginRoutes() {
56     return [
57       ['user.login'],
58       ['user.register'],
59       ['user.pass'],
60     ];
61   }
62
63   /**
64    * Checks user listing local tasks.
65    *
66    * @dataProvider getUserPageRoutes
67    */
68   public function testUserPageLocalTasks($route, $subtask = []) {
69     $tasks = [
70       0 => ['entity.user.canonical', 'entity.user.edit_form'],
71     ];
72     if ($subtask) $tasks[] = $subtask;
73     $this->assertLocalTasks($route, $tasks);
74   }
75
76   /**
77    * Provides a list of routes to test.
78    */
79   public function getUserPageRoutes() {
80     return [
81       ['entity.user.canonical'],
82       ['entity.user.edit_form'],
83     ];
84   }
85
86 }