protected function ModeratedTranslationTest::setUp in Layout Builder Symmetric Translations 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ FunctionalJavascript/ ModeratedTranslationTest.php, line 54
Class
- ModeratedTranslationTest
- Test moderated and translated layout overrides.
Namespace
Drupal\Tests\layout_builder_st\FunctionalJavascriptCode
protected function setUp() {
parent::setUp();
$page = $this
->getSession()
->getPage();
$this->container
->get('state')
->set('test_block_access', TRUE);
// @todo The Layout Builder UI relies on local tasks; fix in
// https://www.drupal.org/project/drupal/issues/2917777.
$this
->drupalPlaceBlock('local_tasks_block');
$this
->createContentType([
'type' => 'bundle_with_section_field',
'new_revision' => TRUE,
]);
$workflow = $this
->createEditorialWorkflow();
$workflow
->getTypePlugin()
->addEntityTypeAndBundle('node', 'bundle_with_section_field');
$workflow
->save();
// Adds a new language.
ConfigurableLanguage::createFromLangcode('it')
->save();
// Enable translation for the node type 'bundle_with_section_field'.
\Drupal::service('content_translation.manager')
->setEnabled('node', 'bundle_with_section_field', TRUE);
$this
->drupalLogin($this
->drupalCreateUser([
'access contextual links',
'configure any layout',
'administer node display',
'administer node fields',
'translate bundle_with_section_field node',
'create content translations',
'edit any bundle_with_section_field content',
'view bundle_with_section_field revisions',
'revert bundle_with_section_field revisions',
'view own unpublished content',
'view latest version',
'use editorial transition create_new_draft',
'use editorial transition publish',
]));
$node = $this
->createNode([
'type' => 'bundle_with_section_field',
'title' => 'The node title',
'body' => [
[
'value' => 'The node body',
],
],
]);
$this
->drupalGet('node/1');
// Create a translation.
$add_translation_url = Url::fromRoute("entity.node.content_translation_add", [
'node' => 1,
'source' => 'en',
'target' => 'it',
]);
$this
->drupalGet($add_translation_url);
$this
->drupalPostForm($add_translation_url, [
'title[0][value]' => 'The translated node title',
'body[0][value]' => 'The translated node body',
], 'Save');
// Allow layout overrides.
$this
->drupalPostForm(static::FIELD_UI_PREFIX . '/display/default', [
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalPostForm(static::FIELD_UI_PREFIX . '/display/default', [
'layout[allow_custom]' => TRUE,
], 'Save');
// Publish both nodes.
$this
->drupalGet($node
->toUrl());
$page
->fillField('new_state', 'published');
$page
->pressButton('Apply');
// Modify the layout.
$this
->drupalGet('it/node/1');
$page
->fillField('new_state', 'published');
$page
->pressButton('Apply');
}