Same name in other branches
- 8.x-1.x tests/src/Functional/EntityCloneEntityFormModeTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneEntityFormModeTest
Test an entity form mode clone.
@group entity_clone
Hierarchy
- class \Drupal\Tests\entity_clone\Functional\EntityCloneEntityFormModeTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of EntityCloneEntityFormModeTest
File
-
tests/
src/ Functional/ EntityCloneEntityFormModeTest.php, line 14
Namespace
Drupal\Tests\entity_clone\FunctionalView source
class EntityCloneEntityFormModeTest extends BrowserTestBase {
use StringTranslationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'entity_clone',
'field_ui',
];
/**
* Theme to enable by default.
*
* @var string
*/
protected $defaultTheme = 'claro';
/**
* Permissions to grant admin user.
*
* @var array
*/
protected $permissions = [
'clone entity_form_mode entity',
'administer display modes',
];
/**
* An administrative user.
*
* With permission to configure entity form modes 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 entity form mode entity clone.
*/
public function testEntityFormModeEntityClone() {
$entity_form_modes = \Drupal::entityTypeManager()->getStorage('entity_form_mode')
->loadByProperties([
'id' => 'user.register',
]);
$entity_form_mode = reset($entity_form_modes);
$edit = [
'label' => 'User register cloned form mode',
'id' => 'register_clone',
];
$this->drupalGet('entity_clone/entity_form_mode/' . $entity_form_mode->id());
$this->submitForm($edit, $this->t('Clone'));
$entity_form_modes = \Drupal::entityTypeManager()->getStorage('entity_form_mode')
->loadByProperties([
'id' => 'user.' . $edit['id'],
]);
$entity_form_mode = reset($entity_form_modes);
$this->assertInstanceOf(EntityFormMode::class, $entity_form_mode, 'Test entity form mode cloned found in database.');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
EntityCloneEntityFormModeTest::$adminUser | protected | property | An administrative user. |
EntityCloneEntityFormModeTest::$defaultTheme | protected | property | Theme to enable by default. |
EntityCloneEntityFormModeTest::$modules | protected static | property | Modules to enable. |
EntityCloneEntityFormModeTest::$permissions | protected | property | Permissions to grant admin user. |
EntityCloneEntityFormModeTest::setUp | protected | function | Sets the test up. |
EntityCloneEntityFormModeTest::testEntityFormModeEntityClone | public | function | Test entity form mode entity clone. |