<?php
namespace Drupal\Tests\paragraphs\Functional\WidgetStable;
class ParagraphsEntityTranslationWithNonTranslatableParagraphs extends ParagraphsTestBase {
protected static $modules = [
'language',
'content_translation',
];
protected function setUp() : void {
parent::setUp();
$this->admin_user = $this
->drupalCreateUser([], NULL, TRUE);
$this
->drupalLogin($this->admin_user);
$edit = array(
'predefined_langcode' => 'de',
);
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, 'Add language');
$edit = array(
'predefined_langcode' => 'fr',
);
$this
->drupalGet('admin/config/regional/language/add');
$this
->submitForm($edit, 'Add language');
$this
->addParagraphedContentType('article', 'field_paragraphs');
$this
->drupalGet('admin/structure/types/manage/article');
$edit = array(
'language_configuration[content_translation]' => TRUE,
);
$this
->drupalGet('admin/structure/types/manage/article');
$this
->submitForm($edit, 'Save');
$this
->drupalGet('admin/structure/types/manage/article');
$edit = array(
'translatable' => FALSE,
);
$this
->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs');
$this
->submitForm($edit, 'Save settings');
$this
->addParagraphsType('test_paragraph_type');
static::fieldUIAddNewField('admin/structure/paragraphs_type/test_paragraph_type', 'text', 'Text', 'string', [
'cardinality' => '-1',
]);
$this
->drupalGet('admin/config/regional/content-language');
}
public function testParagraphsIEFTranslation() {
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('node/add/article');
$edit = [
'title[0][value]' => 'Title English',
];
$this
->submitForm($edit, 'Save');
$this
->clickLink('Translate');
$this
->clickLink('Add', 1);
$this
->assertSession()
->pageTextContains('Title English');
$edit = array(
'title[0][value]' => 'Title French',
);
$this
->submitForm($edit, 'Save (this translation)');
$this
->assertSession()
->pageTextContains('article Title French has been updated.');
$this
->clickLink('Translate');
$this
->clickLink('Add');
$this
->assertSession()
->pageTextContains('Title English');
$edit = array(
'title[0][value]' => 'Title German',
);
$this
->submitForm($edit, 'Save (this translation)');
$this
->assertSession()
->pageTextContains('article Title German has been updated.');
}
}