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

8.0.x
webchick 2013-10-08 21:41:26 -07:00
parent e9843f499e
commit c2d9dfcacf
2 changed files with 18 additions and 4 deletions

View File

@ -88,7 +88,7 @@ class LocalTaskDefault extends PluginBase implements LocalTaskInterface {
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 {

View File

@ -191,21 +191,34 @@ class LocalTaskDefaultTest extends UnitTestCase {
*/
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 @@ class LocalTaskDefaultTest extends UnitTestCase {
*
* @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());