You are here

public function EntityCloneEntityFormModeTest::testEntityFormModeEntityClone in Entity Clone 8

Test entity form mode entity clone.

File

tests/src/Functional/EntityCloneEntityFormModeTest.php, line 59

Class

EntityCloneEntityFormModeTest
Test an entity form mode clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

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
    ->drupalPostForm('entity_clone/entity_form_mode/' . $entity_form_mode
    ->id(), $edit, 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.');
}