public function LocalTasksTest::testLocalTaskBlock in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Menu/LocalTasksTest.php \Drupal\system\Tests\Menu\LocalTasksTest::testLocalTaskBlock()
Tests that local task blocks are configurable to show a specific level.
File
- core/
modules/ system/ src/ Tests/ Menu/ LocalTasksTest.php, line 216 - Contains \Drupal\system\Tests\Menu\LocalTasksTest.
Class
- LocalTasksTest
- Tests local tasks derived from router and added/altered via hooks.
Namespace
Drupal\system\Tests\MenuCode
public function testLocalTaskBlock() {
// Remove the default block and create a new one.
$this->sut
->delete();
$this->sut = $this
->drupalPlaceBlock('local_tasks_block', [
'id' => 'tabs_block',
'primary' => TRUE,
'secondary' => FALSE,
]);
$this
->drupalGet(Url::fromRoute('menu_test.local_task_test_tasks_settings'));
// Verify that local tasks in the first level appear.
$this
->assertLocalTasks([
[
'menu_test.local_task_test_tasks_view',
[],
],
[
'menu_test.local_task_test_tasks_edit',
[],
],
[
'menu_test.local_task_test_tasks_settings',
[],
],
]);
// Verify that local tasks in the second level doesn't appear.
$this
->assertNoLocalTasks(1);
$this->sut
->delete();
$this->sut = $this
->drupalPlaceBlock('local_tasks_block', [
'id' => 'tabs_block',
'primary' => FALSE,
'secondary' => TRUE,
]);
$this
->drupalGet(Url::fromRoute('menu_test.local_task_test_tasks_settings'));
// Verify that local tasks in the first level doesn't appear.
$this
->assertNoLocalTasks(0);
// Verify that local tasks in the second level appear.
$sub_tasks = [
[
'menu_test.local_task_test_tasks_settings_sub1',
[],
],
[
'menu_test.local_task_test_tasks_settings_sub2',
[],
],
[
'menu_test.local_task_test_tasks_settings_sub3',
[],
],
[
'menu_test.local_task_test_tasks_settings_derived',
[
'placeholder' => 'derive1',
],
],
[
'menu_test.local_task_test_tasks_settings_derived',
[
'placeholder' => 'derive2',
],
],
];
$this
->assertLocalTasks($sub_tasks, 1);
}