Issue #2641696 by naveenvalecha, heykarthikwithu, Mac_Weber: Replace deprecated usage of entity_create('menu_link_content') with a direct call to MenuLinkContent::create()
parent
049224c875
commit
a9c6d59c83
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\menu_link_content\Tests;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\system\Entity\Menu;
|
||||
|
||||
|
@ -69,7 +70,7 @@ class LinksTest extends WebTestBase {
|
|||
$parent = $base_options + array(
|
||||
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent'],
|
||||
);
|
||||
$link = entity_create('menu_link_content', $parent);
|
||||
$link = MenuLinkContent::create($parent);
|
||||
$link->save();
|
||||
$links['parent'] = $link->getPluginId();
|
||||
|
||||
|
@ -77,7 +78,7 @@ class LinksTest extends WebTestBase {
|
|||
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child'],
|
||||
'parent' => $links['parent'],
|
||||
);
|
||||
$link = entity_create('menu_link_content', $child_1);
|
||||
$link = MenuLinkContent::create($child_1);
|
||||
$link->save();
|
||||
$links['child-1'] = $link->getPluginId();
|
||||
|
||||
|
@ -85,7 +86,7 @@ class LinksTest extends WebTestBase {
|
|||
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child2/child'],
|
||||
'parent' => $links['child-1'],
|
||||
);
|
||||
$link = entity_create('menu_link_content', $child_1_1);
|
||||
$link = MenuLinkContent::create($child_1_1);
|
||||
$link->save();
|
||||
$links['child-1-1'] = $link->getPluginId();
|
||||
|
||||
|
@ -93,7 +94,7 @@ class LinksTest extends WebTestBase {
|
|||
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child2/child'],
|
||||
'parent' => $links['child-1'],
|
||||
);
|
||||
$link = entity_create('menu_link_content', $child_1_2);
|
||||
$link = MenuLinkContent::create($child_1_2);
|
||||
$link->save();
|
||||
$links['child-1-2'] = $link->getPluginId();
|
||||
|
||||
|
@ -101,7 +102,7 @@ class LinksTest extends WebTestBase {
|
|||
'link' => ['uri' => 'internal:/menu-test/hierarchy/parent/child'],
|
||||
'parent' => $links['parent'],
|
||||
);
|
||||
$link = entity_create('menu_link_content', $child_2);
|
||||
$link = MenuLinkContent::create($child_2);
|
||||
$link->save();
|
||||
$links['child-2'] = $link->getPluginId();
|
||||
|
||||
|
@ -130,7 +131,7 @@ class LinksTest extends WebTestBase {
|
|||
'bundle' => 'menu_link_content',
|
||||
'link' => [['uri' => 'internal:/']],
|
||||
);
|
||||
$link = entity_create('menu_link_content', $options);
|
||||
$link = MenuLinkContent::create($options);
|
||||
$link->save();
|
||||
// Make sure the changed timestamp is set.
|
||||
$this->assertEqual($link->getChangedTime(), REQUEST_TIME, 'Creating a menu link sets the "changed" timestamp.');
|
||||
|
|
|
@ -142,7 +142,7 @@ function _menu_ui_node_save(NodeInterface $node, array $values) {
|
|||
}
|
||||
else {
|
||||
// Create a new menu_link_content entity.
|
||||
$entity = entity_create('menu_link_content', array(
|
||||
$entity = MenuLinkContent::create(array(
|
||||
'link' => ['uri' => 'entity:node/' . $node->id()],
|
||||
'langcode' => $node->getUntranslated()->language()->getId(),
|
||||
));
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\menu_ui\Tests;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\system\Tests\Cache\PageCacheTagsTestBase;
|
||||
use Drupal\system\Entity\Menu;
|
||||
|
||||
|
@ -80,7 +81,7 @@ class MenuCacheTagsTest extends PageCacheTagsTestBase {
|
|||
|
||||
// Verify that after adding a menu link, there is a cache miss.
|
||||
$this->pass('Test addition of menu link.', 'Debug');
|
||||
$menu_link_2 = entity_create('menu_link_content', array(
|
||||
$menu_link_2 = MenuLinkContent::create(array(
|
||||
'id' => '',
|
||||
'parent' => '',
|
||||
'title' => 'Alpaca',
|
||||
|
|
|
@ -198,7 +198,7 @@ class MenuNodeTest extends WebTestBase {
|
|||
$this->assertNoLink($node_title);
|
||||
|
||||
// Add a menu link to the Administration menu.
|
||||
$item = entity_create('menu_link_content', array(
|
||||
$item = MenuLinkContent::create(array(
|
||||
'link' => [['uri' => 'entity:node/' . $node->id()]],
|
||||
'title' => $this->randomMachineName(16),
|
||||
'menu_name' => 'admin',
|
||||
|
@ -220,7 +220,7 @@ class MenuNodeTest extends WebTestBase {
|
|||
// Create a second node.
|
||||
$child_node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
// Assign a menu link to the second node, being a child of the first one.
|
||||
$child_item = entity_create('menu_link_content', array(
|
||||
$child_item = MenuLinkContent::create(array(
|
||||
'link' => [['uri' => 'entity:node/' . $child_node->id()]],
|
||||
'title' => $this->randomMachineName(16),
|
||||
'parent' => $item->getPluginId(),
|
||||
|
|
Loading…
Reference in New Issue