Skip to content
Snippets Groups Projects
Commit 123910f0 authored by Trent Crawford's avatar Trent Crawford
Browse files

Issue #3431965: Drupal 11 compatibility (2.x).

parent f1ca6b67
No related branches found
No related tags found
1 merge request!16Issue #3431965: Drupal 11 compatibility (2.x).
......@@ -2,7 +2,7 @@ name: 'Menu Link Weight'
description: 'Replaces the menu link weight dropdown with a tabledrag widget'
type: module
core: 8.x
core_version_requirement: ^8 || ^9 || ^10
core_version_requirement: ^8 || ^9 || ^10 || ^11
dependencies:
- menu_ui
......
......@@ -307,6 +307,6 @@ function menu_link_weight_menu_link_content_form_submit($form, FormStateInterfac
}
catch (Exception $e) {
$transaction->rollback();
watchdog_exception('menu_link_weight', $e);
\Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('menu_link_weight'), $e), fn() => watchdog_exception('menu_link_weight', $e));
}
}
......@@ -297,6 +297,6 @@ function menu_link_weight_node_form_submit($form, FormStateInterface $form_state
}
catch (Exception $e) {
$transaction->rollback();
watchdog_exception('menu_link_weight', $e);
\Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '10.1.0', fn() => \Drupal\Core\Utility\Error::logException(\Drupal::logger('menu_link_weight'), $e), fn() => watchdog_exception('menu_link_weight', $e));
}
}
......@@ -47,7 +47,7 @@ class ConfigSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
$events[ConfigEvents::SAVE][] = ['onConfigSave', 0];
return $events;
}
......
......@@ -30,7 +30,8 @@ class MenuLinkWeightMenuUiJavascriptTest extends MenuLinkWeightJavascriptTestBas
'title[0][value]' => $node1_title,
'link[0][uri]' => '/' . $node1->toUrl()->getInternalPath(),
];
$this->drupalPostForm('admin/structure/menu/manage/tools/add', $edit, 'Save');
$this->drupalGet('admin/structure/menu/manage/tools/add');
$this->submitForm($edit, 'Save');
$this->assertTrue($this->loadMenuLinkByNode($node1));
$this->assertInstanceOf(MenuLinkInterface::class, $this->loadMenuLinkByNode($node1));
$node1_link = $this->loadMenuLinkByNode($node1);
......@@ -45,7 +46,7 @@ class MenuLinkWeightMenuUiJavascriptTest extends MenuLinkWeightJavascriptTestBas
'menu[menu_link_weight][link_current][weight]' => '-49',
'menu[menu_link_weight][filter.tips_all][weight]' => '-48',
);
$this->drupalPostForm(NULL, $edit, 'Save');
$this->submitForm($edit, 'Save');
$this->assertSession()->pageTextNotContains('The menu link weights have been changed by another user, please try again.');
/** @var \Drupal\menu_link_content\MenuLinkContentInterface[] $links */
......@@ -87,7 +88,8 @@ class MenuLinkWeightMenuUiJavascriptTest extends MenuLinkWeightJavascriptTestBas
'menu[menu_link_weight][link_current][weight]' => '-48',
'menu[menu_link_weight][node.add_page][weight]' => '-47',
);
$this->drupalPostForm('admin/structure/menu/manage/tools/add', $edit, 'Save');
$this->drupalGet('admin/structure/menu/manage/tools/add');
$this->submitForm($edit, 'Save');
// Assert that the link exists.
$this->assertInstanceOf(MenuLinkInterface::class, $this->loadMenuLinkByNode($node2));
......@@ -116,7 +118,8 @@ class MenuLinkWeightMenuUiJavascriptTest extends MenuLinkWeightJavascriptTestBas
'title[0][value]' => $node3_title,
'link[0][uri]' => '/' . $node3->toUrl()->getInternalPath(),
);
$this->drupalPostForm('admin/structure/menu/manage/tools/add', $edit, 'Save');
$this->drupalGet('admin/structure/menu/manage/tools/add');
$this->submitForm($edit, 'Save');
// Assert that the link exists.
$this->assertInstanceOf(MenuLinkInterface::class, $this->loadMenuLinkByNode($node3));
......@@ -143,7 +146,8 @@ class MenuLinkWeightMenuUiJavascriptTest extends MenuLinkWeightJavascriptTestBas
'title[0][value]' => $node4_title,
'link[0][uri]' => '/' . $node4->toUrl()->getInternalPath(),
);
$this->drupalPostForm('admin/structure/menu/manage/tools/add', $edit, 'Save');
$this->drupalGet('admin/structure/menu/manage/tools/add');
$this->submitForm($edit, 'Save');
$link4_id = $this->loadMenuLinkByNode($node4)->getPluginId();
$this->assertLinkWeight($link3_id, -50);
......@@ -160,7 +164,8 @@ class MenuLinkWeightMenuUiJavascriptTest extends MenuLinkWeightJavascriptTestBas
'title[0][value]' => $node5_title,
'link[0][uri]' => '/' . $node5->toUrl()->getInternalPath(),
);
$this->drupalPostForm('admin/structure/menu/manage/tools/add', $edit, 'Save');
$this->drupalGet('admin/structure/menu/manage/tools/add');
$this->submitForm($edit, 'Save');
$link5_id = $this->loadMenuLinkByNode($node5)->getPluginId();
// Assert that the reordering was successful.
......@@ -182,7 +187,8 @@ class MenuLinkWeightMenuUiJavascriptTest extends MenuLinkWeightJavascriptTestBas
'menu[menu_link_weight][link_current][weight]' => '6',
'menu[menu_link_weight][node.add_page][weight]' => '7',
);
$this->drupalPostForm('admin/structure/menu/link/filter.tips_all/edit', $edit, 'Save');
$this->drupalGet('admin/structure/menu/link/filter.tips_all/edit');
$this->submitForm($edit, 'Save');
$this->assertLinkWeight($link1_id, 1);
$this->assertLinkWeight($link2_id, 2);
......
......@@ -18,7 +18,8 @@ class MenuLinkWeightNodeJavascriptTest extends MenuLinkWeightJavascriptTestBase
$edit = array(
'title[0][value]' => $node1_title,
);
$this->drupalPostForm("node/add/{$this->nodeType}", $edit, t('Save'));
$this->drupalGet("node/add/{$this->nodeType}");
$this->submitForm($edit, t('Save'));
// Assert that there is no link for the node.
$this->drupalGet('');
$this->assertSession()->linkNotExists($node1_title);
......@@ -29,7 +30,8 @@ class MenuLinkWeightNodeJavascriptTest extends MenuLinkWeightJavascriptTestBase
'menu[enabled]' => 1,
'menu[title]' => '',
);
$this->drupalPostForm($node1_edit_url, $edit, 'Save');
$this->drupalGet($node1_edit_url);
$this->submitForm($edit, 'Save');
// Assert that there is no link for the node.
$this->drupalGet('');
$this->assertSession()->linkNotExists($node1_title);
......@@ -46,7 +48,7 @@ class MenuLinkWeightNodeJavascriptTest extends MenuLinkWeightJavascriptTestBase
'menu[menu_link_weight][link_current][weight]' => '-49',
'menu[menu_link_weight][filter.tips_all][weight]' => '-48',
);
$this->drupalPostForm(NULL, $edit, 'Save');
$this->submitForm($edit, 'Save');
$this->assertSession()->pageTextNotContains('The menu link weights have been changed by another user, please try again.');
// Assert that the link exists.
$this->drupalGet('');
......@@ -85,7 +87,8 @@ class MenuLinkWeightNodeJavascriptTest extends MenuLinkWeightJavascriptTestBase
'menu[menu_link_weight][link_current][weight]' => '-48',
'menu[menu_link_weight][node.add_page][weight]' => '-47',
);
$this->drupalPostForm("node/add/{$this->nodeType}", $edit, t('Save'));
$this->drupalGet("node/add/{$this->nodeType}");
$this->submitForm($edit, t('Save'));
// Assert that the link exists.
$this->drupalGet('');
$this->assertSession()->linkExists($node2_title);
......@@ -115,7 +118,8 @@ class MenuLinkWeightNodeJavascriptTest extends MenuLinkWeightJavascriptTestBase
'menu[enabled]' => TRUE,
'menu[title]' => $node3_title,
);
$this->drupalPostForm("node/add/{$this->nodeType}", $edit, t('Save'));
$this->drupalGet("node/add/{$this->nodeType}");
$this->submitForm($edit, t('Save'));
// Assert that the link exists.
$this->drupalGet('');
......@@ -143,8 +147,8 @@ class MenuLinkWeightNodeJavascriptTest extends MenuLinkWeightJavascriptTestBase
'menu[enabled]' => TRUE,
'menu[title]' => $node4_title,
);
$this->drupalPostForm("node/add/{$this->nodeType}", $edit, t('Save'));
$this->drupalGet("node/add/{$this->nodeType}");
$this->submitForm($edit, t('Save'));
// Assert that the link exists.
$this->drupalGet('');
......@@ -168,8 +172,8 @@ class MenuLinkWeightNodeJavascriptTest extends MenuLinkWeightJavascriptTestBase
'menu[enabled]' => 1,
'menu[title]' => $node5_title,
);
$this->drupalPostForm("node/add/{$this->nodeType}", $edit, t('Save'));
$this->drupalGet("node/add/{$this->nodeType}");
$this->submitForm($edit, t('Save'));
/** @var \Drupal\menu_link_content\MenuLinkContentInterface[] $links */
$links = $this->contentMenuLinkStorage->loadByProperties(['title' => $node5_title]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment