Unit Test
Setup
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->directoryList = ['module_name' => 'path/to/module'];
parent::setUp();
}
Display
Existence of local task plugin
/**
* Tests local task existence.
*
* @dataProvider getAggregatorAdminRoutes
*/
public function testAggregatorAdminLocalTasks($route) {
$this->assertLocalTasks($route, [
0 => ['aggregator.admin_overview', 'aggregator.admin_settings'],
]);
}
See also: assertLocalTasks
Data provider
/**
* Provides a list of routes to test.
*/
public function getAggregatorAdminRoutes() {
return [
['aggregator.admin_overview'],
['aggregator.admin_settings'],
];
}
Summary
<?php
namespace Drupal\Tests\[module_name]\Unit\Menu;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
/**
* Tests existence of aggregator local tasks.
*
* @group aggregator
*/
class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->directoryList = ['module_name' => 'path/to/module'];
parent::setUp();
}
/**
* Tests local task existence.
*
* @dataProvider getAggregatorAdminRoutes
*/
public function testAggregatorAdminLocalTasks($route) {
$this->assertLocalTasks($route, [
0 => ['aggregator.admin_overview', 'aggregator.admin_settings'],
]);
}
/**
* Provides a list of routes to test.
*/
public function getAggregatorAdminRoutes() {
return [
['aggregator.admin_overview'],
['aggregator.admin_settings'],
];
}
}