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

Create a shortcut set and test a clone.

@group entity_clone

Hierarchy

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

Expanded class hierarchy of EntityCloneShortcutSetTest

File

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

Namespace

Drupal\Tests\entity_clone\Functional
View source
class EntityCloneShortcutSetTest extends BrowserTestBase {
    use StringTranslationTrait;
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'entity_clone',
        'shortcut',
    ];
    
    /**
     * Theme to enable by default.
     *
     * @var string
     */
    protected $defaultTheme = 'claro';
    
    /**
     * Permissions to grant admin user.
     *
     * @var array
     */
    protected $permissions = [
        'clone shortcut_set entity',
        'administer shortcuts',
    ];
    
    /**
     * An administrative user with permission to configure shortcuts 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 shortcut set entity clone.
     */
    public function testShortcutSetEntityClone() {
        $edit = [
            'id' => 'test_shortcut_set_cloned',
            'label' => 'Test shortcut set cloned',
        ];
        $this->drupalGet('entity_clone/shortcut_set/default');
        $this->submitForm($edit, $this->t('Clone'));
        $shortcut_sets = \Drupal::entityTypeManager()->getStorage('shortcut_set')
            ->loadByProperties([
            'id' => $edit['id'],
        ]);
        $shortcut_set = reset($shortcut_sets);
        $this->assertInstanceOf(ShortcutSet::class, $shortcut_set, 'Test default shortcut set cloned found in database.');
    }

}

Members

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