function LanguageConfigurationElementTest::testNodeTypeDelete

Same name in other branches
  1. 9 core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php \Drupal\Tests\language\Functional\LanguageConfigurationElementTest::testNodeTypeDelete()
  2. 8.9.x core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php \Drupal\Tests\language\Functional\LanguageConfigurationElementTest::testNodeTypeDelete()
  3. 10 core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php \Drupal\Tests\language\Functional\LanguageConfigurationElementTest::testNodeTypeDelete()

Tests the language settings are deleted on bundle delete.

File

core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php, line 211

Class

LanguageConfigurationElementTest
Tests the features of the language configuration element field.

Namespace

Drupal\Tests\language\Functional

Code

public function testNodeTypeDelete() : void {
    // Create the article content type first if the profile used is not the
    // standard one.
    if ($this->profile != 'standard') {
        $this->drupalCreateContentType([
            'type' => 'article',
            'name' => 'Article',
        ]);
    }
    $admin_user = $this->drupalCreateUser([
        'administer content types',
    ]);
    $this->drupalLogin($admin_user);
    // Create language configuration for the articles.
    $edit = [
        'language_configuration[langcode]' => 'authors_default',
        'language_configuration[language_alterable]' => TRUE,
    ];
    $this->drupalGet('admin/structure/types/manage/article');
    $this->submitForm($edit, 'Save');
    // Check the language default configuration for articles is present.
    $configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')
        ->load('node.article');
    $this->assertNotEmpty($configuration, 'The language configuration is present.');
    // Delete 'article' bundle.
    $this->drupalGet('admin/structure/types/manage/article/delete');
    $this->submitForm([], 'Delete');
    // Check that the language configuration has been deleted.
    \Drupal::entityTypeManager()->getStorage('language_content_settings')
        ->resetCache();
    $configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')
        ->load('node.article');
    $this->assertNull($configuration, 'The language configuration was deleted after bundle was deleted.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.