Same name in other branches
- 2.x tests/src/Functional/EntityCloneRoleTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneRoleTest
Create a role and test a clone.
@group entity_clone
Hierarchy
- class \Drupal\Tests\entity_clone\Functional\EntityCloneRoleTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of EntityCloneRoleTest
File
-
tests/
src/ Functional/ EntityCloneRoleTest.php, line 14
Namespace
Drupal\Tests\entity_clone\FunctionalView source
class EntityCloneRoleTest extends BrowserTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_clone',
'user',
];
/**
* Theme to enable by default.
*
* @var string
*/
protected $defaultTheme = 'claro';
/**
* Permissions to grant admin user.
*
* @var array
*/
protected $permissions = [
'administer permissions',
'clone user_role entity',
];
/**
* An administrative user with permission to configure roles 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 role entity clone.
*/
public function testRoleEntityClone() {
$edit = [
'label' => 'Test role for clone',
'id' => 'test_role_for_clone',
];
$this->drupalGet("/admin/people/roles/add");
$this->submitForm($edit, $this->t('Save'));
$roles = \Drupal::entityTypeManager()->getStorage('user_role')
->loadByProperties([
'id' => $edit['id'],
]);
$role = reset($roles);
$edit = [
'id' => 'test_role_cloned',
'label' => 'Test role cloned',
];
$this->drupalGet('entity_clone/user_role/' . $role->id());
$this->submitForm($edit, $this->t('Clone'));
$roles = \Drupal::entityTypeManager()->getStorage('user_role')
->loadByProperties([
'id' => $edit['id'],
]);
$role = reset($roles);
$this->assertInstanceOf(Role::class, $role, 'Test role cloned found in database.');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
EntityCloneRoleTest::$adminUser | protected | property | An administrative user with permission to configure roles settings. |
EntityCloneRoleTest::$defaultTheme | protected | property | Theme to enable by default. |
EntityCloneRoleTest::$modules | protected static | property | Modules to enable. |
EntityCloneRoleTest::$permissions | protected | property | Permissions to grant admin user. |
EntityCloneRoleTest::setUp | protected | function | Sets the test up. |
EntityCloneRoleTest::testRoleEntityClone | public | function | Test role entity clone. |