Same name in other branches
  1. 8.x-1.x tests/src/Functional/EntityCloneMenuTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneMenuTest::testMenuEntityClone()

Test menu entity clone.

File

tests/src/Functional/EntityCloneMenuTest.php, line 62

Class

EntityCloneMenuTest
Create a menu and test a clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

public function testMenuEntityClone() {
    $menus = \Drupal::entityTypeManager()->getStorage('menu')
        ->loadByProperties([
        'id' => 'account',
    ]);
    $menu = reset($menus);
    $edit = [
        'label' => 'Test menu cloned',
        'id' => 'test-menu-cloned',
    ];
    $this->drupalGet('entity_clone/menu/' . $menu->id());
    $this->submitForm($edit, $this->t('Clone'));
    $menus = \Drupal::entityTypeManager()->getStorage('menu')
        ->loadByProperties([
        'id' => $edit['id'],
    ]);
    $menu = reset($menus);
    $this->assertInstanceOf(Menu::class, $menu, 'Test menu cloned found in database.');
}