You are here

public function LinksTest::testCreateLink in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/menu_link_content/src/Tests/LinksTest.php \Drupal\menu_link_content\Tests\LinksTest::testCreateLink()

Assert that a link entity's created timestamp is set.

File

core/modules/menu_link_content/src/Tests/LinksTest.php, line 126
Contains \Drupal\menu_link_content\Tests\LinksTest.

Class

LinksTest
Tests handling of menu links hierarchies.

Namespace

Drupal\menu_link_content\Tests

Code

public function testCreateLink() {
  $options = array(
    'menu_name' => 'menu_test',
    'bundle' => 'menu_link_content',
    'link' => [
      [
        'uri' => 'internal:/',
      ],
    ],
  );
  $link = entity_create('menu_link_content', $options);
  $link
    ->save();

  // Make sure the changed timestamp is set.
  $this
    ->assertEqual($link
    ->getChangedTime(), REQUEST_TIME, 'Creating a menu link sets the "changed" timestamp.');
  $options = array(
    'title' => 'Test Link',
  );
  $link->link->options = $options;
  $link->changed->value = 0;
  $link
    ->save();

  // Make sure the changed timestamp is updated.
  $this
    ->assertEqual($link
    ->getChangedTime(), REQUEST_TIME, 'Changing a menu link sets "changed" timestamp.');
}