Commit c2d9dfca authored by webchick's avatar webchick

Issue #2100651 by dawehner, neclimdul: Fixed local task plugin id check for derivatives.

parent e9843f49
......@@ -88,7 +88,7 @@ public function getTitle() {
public function getWeight() {
// By default the weight is 0, or -10 for the root tab.
if (!isset($this->pluginDefinition['weight'])) {
if ($this->pluginDefinition['tab_root_id'] == $this->pluginDefinition['id']) {
if ($this->pluginDefinition['tab_root_id'] == $this->pluginId) {
$this->pluginDefinition['weight'] = -10;
}
else {
......
......@@ -191,21 +191,34 @@ public function testGetRouteParametersForDynamicRouteWithUpcastedParameters() {
*/
public function providerTestGetWeight() {
return array(
array(array('weight' => 314), 314),
// Manually specify a weight, so this is used.
array(array('weight' => 314), 'test_id', 314),
// Ensure that a default tab get a lower weight.
array(
array(
'tab_root_id' => 'local_task_default',
'id' => 'local_task_default'
),
'local_task_default',
-10
),
// If the root ID is different to the ID of the tab, ignore it.
array(
array(
'tab_root_id' => 'local_task_example',
'id' => 'local_task_default'
),
0
'local_task_default',
0,
),
// Ensure that a default tab of a derivative gets the default value.
array(
array(
'tab_root_id' => 'local_task_derivative_default:example_id',
'id' => 'local_task_derivative_default'
),
'local_task_derivative_default:example_id',
-10,
),
);
}
......@@ -217,8 +230,9 @@ public function providerTestGetWeight() {
*
* @see \Drupal\Core\Menu\LocalTaskDefault::getWeight()
*/
public function testGetWeight(array $plugin_definition, $expected_weight) {
public function testGetWeight(array $plugin_definition, $plugin_id, $expected_weight) {
$this->pluginDefinition = $plugin_definition;
$this->pluginId = $plugin_id;
$this->setupLocalTaskDefault();
$this->assertEquals($expected_weight, $this->localTaskBase->getWeight());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment