function LinksetControllerTestBase::createMenuItem
Same name in other branches
- 11.x core/modules/system/tests/src/Functional/Menu/LinksetControllerTestBase.php \Drupal\Tests\system\Functional\Menu\LinksetControllerTestBase::createMenuItem()
Creates, saves, and returns a new menu link content entity.
Parameters
array $values: Menu field values.
array $options: Menu options.
Return value
\Drupal\menu_link_content\MenuLinkContentInterface The newly created menu link content entity.
Throws
\Drupal\Core\Entity\EntityStorageException
See also
\Drupal\menu_link_content\MenuLinkContentInterface::create()
3 calls to LinksetControllerTestBase::createMenuItem()
- LinksetControllerMultiLingualTest::setUp in core/
modules/ system/ tests/ src/ Functional/ Menu/ LinksetControllerMultiLingualTest.php - Test set up.
- LinksetControllerTest::setUp in core/
modules/ system/ tests/ src/ Functional/ Menu/ LinksetControllerTest.php - Test set up.
- LinksetControllerTest::testCacheability in core/
modules/ system/ tests/ src/ Functional/ Menu/ LinksetControllerTest.php - Test the cacheability of the linkset endpoint.
File
-
core/
modules/ system/ tests/ src/ Functional/ Menu/ LinksetControllerTestBase.php, line 128
Class
- LinksetControllerTestBase
- A base class for implementing LinksetController tests.
Namespace
Drupal\Tests\system\Functional\MenuCode
protected function createMenuItem(array $values, array $options = []) : MenuLinkContentInterface {
if (!empty($options)) {
$values['link'] = [
'uri' => $values['link'],
'options' => $options,
];
}
$link_content = MenuLinkContent::create($values);
assert($link_content instanceof MenuLinkContentInterface);
$link_content->save();
return $link_content;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.