You are here

public function LanguageConfigurationElementTest::testNodeTypeDelete in Drupal 9

Same name and namespace in other branches
  1. 8 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 204

Class

LanguageConfigurationElementTest
Tests the features of the language configuration element field.

Namespace

Drupal\Tests\language\Functional

Code

public function testNodeTypeDelete() {

  // 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 content type');

  // 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.');
}