public function MenuLinksOriginTest::testCreateLink in Menu Item Extras 8.2
Assert that a link entity's created timestamp is set.
File
- tests/
src/ Kernel/ MenuLinksOriginTest.php, line 151
Class
- MenuLinksOriginTest
- Tests handling of menu links hierarchies.
Namespace
Drupal\Tests\menu_item_extras\KernelCode
public function testCreateLink() {
$options = [
'menu_name' => 'menu_test',
'bundle' => 'menu_link_content',
'link' => [
[
'uri' => 'internal:/',
],
],
'title' => 'Link test',
];
$link = MenuLinkContent::create($options);
$link
->save();
// Make sure the changed timestamp is set.
$this
->assertNotEmpty($link
->getChangedTime(), 'Creating a menu link sets the "changed" timestamp.');
$options = [
'title' => 'Test Link',
];
$link->link->options = $options;
$link->changed->value = 0;
$link
->save();
// Make sure the changed timestamp is updated.
$this
->assertNotEmpty($link
->getChangedTime(), 'Changing a menu link sets "changed" timestamp.');
}