ContentTranslationEnableTest.php in Drupal 9
File
core/modules/content_translation/tests/src/Functional/ContentTranslationEnableTest.php
View source
<?php
namespace Drupal\Tests\content_translation\Functional;
use Drupal\Tests\BrowserTestBase;
class ContentTranslationEnableTest extends BrowserTestBase {
protected static $modules = [
'entity_test',
'menu_link_content',
'node',
];
protected $defaultTheme = 'stark';
public function testEnable() {
$this
->drupalLogin($this->rootUser);
$edit = [
'modules[content_translation][enable]' => TRUE,
'modules[language][enable]' => TRUE,
];
$this
->drupalGet('admin/modules');
$this
->submitForm($edit, 'Install');
$this
->assertSession()
->pageTextContains('This site has only a single language enabled. Add at least one more language in order to translate content.');
$this
->assertSession()
->pageTextContains('Enable translation for content types, taxonomy vocabularies, accounts, or any other element you wish to translate.');
$this
->drupalGet('admin/reports/status');
$this
->assertSession()
->elementTextEquals('css', "details.system-status-report__entry summary:contains('Entity/field definitions') + div", 'Up to date');
$this
->drupalGet('admin/config/regional/content-language');
$this
->assertSession()
->responseNotContains('entity_types[node]');
$edit = [
'entity_types[menu_link_content]' => TRUE,
'settings[menu_link_content][menu_link_content][translatable]' => TRUE,
'entity_types[entity_test_mul]' => TRUE,
'settings[entity_test_mul][entity_test_mul][translatable]' => TRUE,
];
$this
->submitForm($edit, 'Save configuration');
$this
->drupalGet('admin/reports/status');
$this
->assertSession()
->elementTextEquals('css', "details.system-status-report__entry summary:contains('Entity/field definitions') + div", 'Up to date');
$edit = [
'name' => 'foo',
'title_label' => 'title for foo',
'type' => 'foo',
];
$this
->drupalGet('admin/structure/types/add');
$this
->submitForm($edit, 'Save content type');
$this
->drupalGet('admin/config/regional/content-language');
$this
->assertSession()
->responseContains('entity_types[node]');
}
}