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

Create a menu and test a clone.

@group entity_clone

Hierarchy

  • class \Drupal\Tests\entity_clone\Functional\EntityCloneMenuTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait

Expanded class hierarchy of EntityCloneMenuTest

File

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

Namespace

Drupal\Tests\entity_clone\Functional
View source
class EntityCloneMenuTest extends BrowserTestBase {
    use StringTranslationTrait;
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'entity_clone',
        'menu_ui',
    ];
    
    /**
     * Theme to enable by default.
     *
     * @var string
     */
    protected $defaultTheme = 'claro';
    
    /**
     * Permissions to grant admin user.
     *
     * @var array
     */
    protected $permissions = [
        'clone menu entity',
        'administer menu',
    ];
    
    /**
     * An administrative user with permission to configure menus settings.
     *
     * @var \Drupal\user\UserInterface
     */
    protected $adminUser;
    
    /**
     * Sets the test up.
     */
    protected function setUp() : void {
        parent::setUp();
        $this->adminUser = $this->drupalCreateUser($this->permissions);
        $this->drupalLogin($this->adminUser);
    }
    
    /**
     * Test menu entity clone.
     */
    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.');
    }

}

Members

Title Sort descending Modifiers Object type Summary
EntityCloneMenuTest::$adminUser protected property An administrative user with permission to configure menus settings.
EntityCloneMenuTest::$defaultTheme protected property Theme to enable by default.
EntityCloneMenuTest::$modules protected static property Modules to enable.
EntityCloneMenuTest::$permissions protected property Permissions to grant admin user.
EntityCloneMenuTest::setUp protected function Sets the test up.
EntityCloneMenuTest::testMenuEntityClone public function Test menu entity clone.