You are here

public function EntityCloneLanguageTest::testLanguageEntityClone in Entity Clone 8

Test language entity clone.

File

tests/src/Functional/EntityCloneLanguageTest.php, line 58

Class

EntityCloneLanguageTest
Create an language and test a clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

public function testLanguageEntityClone() {
  $edit = [
    'predefined_langcode' => 'fr',
  ];
  $this
    ->drupalPostForm("/admin/config/regional/language/add", $edit, t('Add language'));
  $languages = \Drupal::entityTypeManager()
    ->getStorage('configurable_language')
    ->loadByProperties([
    'id' => 'fr',
  ]);
  $language = reset($languages);
  $edit = [
    'id' => 'test_language_cloned',
    'label' => 'French language cloned',
  ];
  $this
    ->drupalPostForm('entity_clone/configurable_language/' . $language
    ->id(), $edit, t('Clone'));
  $languages = \Drupal::entityTypeManager()
    ->getStorage('configurable_language')
    ->loadByProperties([
    'id' => $edit['id'],
  ]);
  $language = reset($languages);
  $this
    ->assertInstanceOf(ConfigurableLanguage::class, $language, 'Test language cloned found in database.');
}