You are here

public function LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved in Lingotek Translation 3.7.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  2. 4.0.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  3. 3.0.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  4. 3.1.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  5. 3.2.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  6. 3.3.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  7. 3.4.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  8. 3.5.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  9. 3.6.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()
  10. 3.8.x tests/src/Functional/LingotekNodeParagraphsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeParagraphsTranslationTest::testParagraphIsRemovedIfTranslationIsRemoved()

Tests that when we remove a paragraph from a translated source node, when reuploading and translating the target doesn't contain the paragraph.

File

tests/src/Functional/LingotekNodeParagraphsTranslationTest.php, line 469

Class

LingotekNodeParagraphsTranslationTest
Tests translating a node with multiple locales including paragraphs.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testParagraphIsRemovedIfTranslationIsRemoved() {
  $this
    ->testNodeWithParagraphsTranslation();
  $this
    ->drupalGet('node/1/edit');
  $this
    ->drupalPostForm(NULL, [], 'Remove');
  $this
    ->drupalPostForm(NULL, [], 'Confirm removal');
  $this
    ->drupalPostForm(NULL, [], 'Save (this translation)');

  // Check that only the configured fields have been uploaded, including metatags.
  $data = json_decode(\Drupal::state()
    ->get('lingotek.uploaded_content', '[]'), TRUE);
  $this
    ->assertTrue(isset($data['field_paragraphs_demo']));
  $this
    ->assertEmpty($data['field_paragraphs_demo']);

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'node+paragraphs_removed');
  $this
    ->clickLink('Translate');

  // Check translation status.
  $this
    ->clickLink('Check translation status');
  $this
    ->assertText('The es_AR translation for node Llamas are cool is ready for download.');

  // Download translation.
  $this
    ->clickLink('Download completed translation');
  $this
    ->assertText('The translation of node Llamas are cool into es_AR has been downloaded.');

  // The content is translated and published.
  $this
    ->clickLink('Las llamas son chulas');
  $this
    ->assertText('Las llamas son chulas');
  $this
    ->assertNoText('Las llamas son muy chulas');
}