class ParagraphsEntityTranslationWithNonTranslatableParagraphs

Same name in this branch
  1. 8.x-1.x paragraphs/tests/src/Functional/WidgetStable/ParagraphsEntityTranslationWithNonTranslatableParagraphs.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsEntityTranslationWithNonTranslatableParagraphs
  2. 8.x-1.x paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsEntityTranslationWithNonTranslatableParagraphs.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsEntityTranslationWithNonTranslatableParagraphs

Tests the translation of heavily nested / specialized setup.

@group paragraphs

Hierarchy

Expanded class hierarchy of ParagraphsEntityTranslationWithNonTranslatableParagraphs

File

paragraphs/tests/src/Functional/WidgetStable/ParagraphsEntityTranslationWithNonTranslatableParagraphs.php, line 10

Namespace

Drupal\Tests\paragraphs\Functional\WidgetStable
View source
class ParagraphsEntityTranslationWithNonTranslatableParagraphs extends ParagraphsTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = [
    'language',
    'content_translation',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->admin_user = $this
      ->drupalCreateUser([], NULL, TRUE);
    $this
      ->drupalLogin($this->admin_user);

    // Add a languages.
    $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');

    // Create article content type with a paragraphs field.
    $this
      ->addParagraphedContentType('article', 'field_paragraphs');
    $this
      ->drupalGet('admin/structure/types/manage/article');

    // Make content type translatable.
    $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');

    // Ensue the paragraphs field itself isn't translatable - this would be a
    // currently not supported configuration otherwise.
    $edit = array(
      'translatable' => FALSE,
    );
    $this
      ->drupalGet('admin/structure/types/manage/article/fields/node.article.field_paragraphs');
    $this
      ->submitForm($edit, 'Save settings');

    // Add Paragraphs type.
    $this
      ->addParagraphsType('test_paragraph_type');

    // Configure Paragraphs type.
    static::fieldUIAddNewField('admin/structure/paragraphs_type/test_paragraph_type', 'text', 'Text', 'string', [
      'cardinality' => '-1',
    ]);

    // Just for verbose-sake - check the content language settings.
    $this
      ->drupalGet('admin/config/regional/content-language');
  }

  /**
   * Tests the revision of paragraphs.
   */
  public function testParagraphsIEFTranslation() {
    $this
      ->drupalLogin($this->admin_user);

    // Create node with one paragraph.
    $this
      ->drupalGet('node/add/article');

    // Set the values and save.
    $edit = [
      'title[0][value]' => 'Title English',
    ];
    $this
      ->submitForm($edit, 'Save');

    // Add french translation.
    $this
      ->clickLink('Translate');
    $this
      ->clickLink('Add', 1);

    // Make sure that the original paragraph text is displayed.
    $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.');

    // Add german translation.
    $this
      ->clickLink('Translate');
    $this
      ->clickLink('Add');

    // Make sure that the original paragraph text is displayed.
    $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.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ParagraphsEntityTranslationWithNonTranslatableParagraphs::$modules protected static property Modules to enable. Overrides ParagraphsTestBase::$modules
ParagraphsEntityTranslationWithNonTranslatableParagraphs::setUp protected function Overrides ParagraphsTestBase::setUp
ParagraphsEntityTranslationWithNonTranslatableParagraphs::testParagraphsIEFTranslation public function Tests the revision of paragraphs.
ParagraphsTestBase::$admin_permissions protected property List of permissions used by loginAsAdmin().
ParagraphsTestBase::$admin_user protected property Drupal user object created by loginAsAdmin(). 1
ParagraphsTestBase::$defaultTheme protected property 2
ParagraphsTestBase::loginAsAdmin function Creates an user with admin permissions and log in.
ParagraphsTestBase::removeDefaultParagraphType protected function Removes the default paragraph type. Overrides ParagraphsTestBase::removeDefaultParagraphType
ParagraphsTestBase::setAddMode protected function Sets the Paragraphs widget add mode. Overrides ParagraphsTestBase::setAddMode
ParagraphsTestBase::setAllowedParagraphsTypes protected function Sets the allowed Paragraphs types that can be added.
ParagraphsTestBase::setDefaultParagraphType protected function Sets the default paragraph type.
ParagraphsTestBase::setParagraphsTypeWeight protected function Sets the weight of a given Paragraphs type.
ParagraphsTestBase::setParagraphsWidgetMode protected function Sets the Paragraphs widget display mode.
ParagraphsTestBaseTrait::$workflow protected property The workflow entity.
ParagraphsTestBaseTrait::addFieldtoParagraphType protected function Adds a field to a given paragraph type.
ParagraphsTestBaseTrait::addParagraphedContentType protected function Adds a content type with a Paragraphs field.
ParagraphsTestBaseTrait::addParagraphsField protected function Adds a Paragraphs field to a given entity type.
ParagraphsTestBaseTrait::addParagraphsType protected function Adds a Paragraphs type.
ParagraphsTestBaseTrait::addParagraphsTypeIcon protected function Adds an icon to a paragraphs type.
ParagraphsTestBaseTrait::coreVersion protected function Checks the core version.
ParagraphsTestBaseTrait::createEditorialWorkflow protected function Creates a workflow entity.
ParagraphsTestBaseTrait::setParagraphsWidgetSettings protected function Sets some of the settings of a paragraphs field widget.