Same name in other branches
  1. 2.x tests/src/Functional/EntityCloneLanguageTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneLanguageTest

Create an language and test a clone.

@group entity_clone

Hierarchy

  • class \Drupal\Tests\entity_clone\Functional\EntityCloneLanguageTest extends \Drupal\Tests\BrowserTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait

Expanded class hierarchy of EntityCloneLanguageTest

Fichier

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

Namespace

Drupal\Tests\entity_clone\Functional
View source
class EntityCloneLanguageTest extends BrowserTestBase {
    use StringTranslationTrait;
    
    /**
     * Modules to enable.
     *
     * @var array
     */
    protected static $modules = [
        'entity_clone',
        'language',
    ];
    
    /**
     * Theme to enable by default.
     *
     * @var string
     */
    protected $defaultTheme = 'claro';
    
    /**
     * Permissions to grant admin user.
     *
     * @var array
     */
    protected $permissions = [
        'administer languages',
        'clone configurable_language entity',
    ];
    
    /**
     * An administrative user with permission to configure languages 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 language entity clone.
     */
    public function testLanguageEntityClone() {
        $edit = [
            'predefined_langcode' => 'fr',
        ];
        $this->drupalGet("/admin/config/regional/language/add");
        $this->submitForm($edit, $this->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->drupalGet('entity_clone/configurable_language/' . $language->id());
        $this->submitForm($edit, $this->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.');
    }

}

Members

Titre Trier par ordre décroissant Modifiers Object type Résumé
EntityCloneLanguageTest::$adminUser protected property An administrative user with permission to configure languages settings.
EntityCloneLanguageTest::$defaultTheme protected property Theme to enable by default.
EntityCloneLanguageTest::$modules protected static property Modules to enable.
EntityCloneLanguageTest::$permissions protected property Permissions to grant admin user.
EntityCloneLanguageTest::setUp protected function Sets the test up.
EntityCloneLanguageTest::testLanguageEntityClone public function Test language entity clone.