public function ParagraphsConfigTest::testFieldTranslationDisabled

Same name in this branch
  1. 8.x-1.x paragraphs/tests/src/Functional/WidgetStable/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsConfigTest::testFieldTranslationDisabled()
  2. 8.x-1.x paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsConfigTest::testFieldTranslationDisabled()

Tests adding paragraphs with no translation enabled.

File

paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php, line 27

Class

ParagraphsConfigTest
Tests paragraphs configuration.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

public function testFieldTranslationDisabled() {
  $this
    ->loginAsAdmin([
    'administer languages',
    'administer content translation',
    'create content translations',
    'translate any entity',
  ]);

  // Add a paragraphed content type.
  $this
    ->addParagraphedContentType('paragraphed_test', 'paragraphs_field', 'entity_reference_paragraphs');
  $this
    ->addParagraphsType('paragraph_type_test');
  $this
    ->addParagraphsType('text');

  // Add a second language.
  ConfigurableLanguage::createFromLangcode('de')
    ->save();

  // Enable translation for paragraphed content type. Do not enable
  // translation for the ERR paragraphs field nor for fields on the
  // paragraph type.
  $edit = [
    'entity_types[node]' => TRUE,
    'settings[node][paragraphed_test][translatable]' => TRUE,
    'settings[node][paragraphed_test][fields][paragraphs_field]' => FALSE,
  ];
  $this
    ->drupalGet('admin/config/regional/content-language');
  $this
    ->submitForm($edit, 'Save configuration');

  // Create a node with a paragraph.
  $this
    ->drupalGet('node/add/paragraphed_test');
  $this
    ->submitForm([], 'paragraphs_field_paragraph_type_test_add_more');
  $edit = [
    'title[0][value]' => 'paragraphed_title',
  ];
  $this
    ->submitForm($edit, 'Save');

  // Attempt to add a translation.
  $node = $this
    ->drupalGetNodeByTitle('paragraphed_title');
  $this
    ->drupalGet('node/' . $node
    ->id() . '/translations');
  $this
    ->clickLink('Add');

  // Save the translation.
  $this
    ->submitForm([], 'Save (this translation)');
  $this
    ->assertSession()
    ->pageTextContains('paragraphed_test paragraphed_title has been updated.');
}