Same name in other branches
- 2.x tests/src/Functional/EntityCloneRoleTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneRoleTest::testRoleEntityClone()
Test role entity clone.
File
-
tests/
src/ Functional/ EntityCloneRoleTest.php, line 62
Class
- EntityCloneRoleTest
- Create a role and test a clone.
Namespace
Drupal\Tests\entity_clone\FunctionalCode
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.');
}