You are here

public function LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateAllDocumentsWithCancelledDocuments in Lingotek Translation 3.5.x

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

File

tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php, line 233

Class

LingotekUtilitiesDisassociateAllDocumentsTest
Tests disassociating all site documents.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testDisassociateAllDocumentsWithCancelledDocuments() {
  $this
    ->createAndCancelANode();

  // There's one cancelled and one current.
  $this
    ->goToContentBulkManagementForm('node');
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CANCELLED);
  $this
    ->createAndCancelATerm();

  // There's one cancelled and one current.
  $this
    ->goToContentBulkManagementForm('taxonomy_term');
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CANCELLED);
  $this
    ->createAndCancelANodeType();

  // There's one cancelled and one current.
  $this
    ->goToConfigBulkManagementForm('node_type');
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CANCELLED);
  $this
    ->createAndCancelAConfig();

  // There's one cancelled and one current.
  $this
    ->goToConfigBulkManagementForm('node_type');
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CURRENT);
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_CANCELLED);

  // Disassociate.
  $this
    ->drupalGet('/admin/lingotek/settings');
  $this
    ->drupalPostForm(NULL, [], 'Disassociate');
  $this
    ->assertRaw("Are you sure you want to disassociate everything from Lingotek?");
  $this
    ->drupalPostForm(NULL, [], 'Disassociate');
  $this
    ->assertText('All translations have been disassociated.');
  $node = Node::load(1);
  $term = Term::load(1);

  /** @var \Drupal\lingotek\LingotekContentTranslationServiceInterface $content_translation_service */
  $content_translation_service = \Drupal::service('lingotek.content_translation');

  /** @var \Drupal\lingotek\LingotekConfigTranslationServiceInterface $config_translation_service */
  $config_translation_service = \Drupal::service('lingotek.config_translation');

  // Ensure we have disassociated the node.
  $this
    ->assertNull($content_translation_service
    ->getDocumentId($node), 'The node has been disassociated from its Lingotek Document ID');
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $content_translation_service
    ->getSourceStatus($node));

  // Ensure we have disassociated the term.
  $this
    ->assertNull($content_translation_service
    ->getDocumentId($term), 'The term has been disassociated from its Lingotek Document ID');
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $content_translation_service
    ->getSourceStatus($term));

  // Ensure we are disassociated the article type.
  $article_type = \Drupal::entityTypeManager()
    ->getStorage('node_type')
    ->load('article');
  $this
    ->assertNull($config_translation_service
    ->getDocumentId($article_type), 'The article node type has been disassociated from its Lingotek Document ID');
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $config_translation_service
    ->getSourceStatus($article_type));

  // Ensure we are disassociated the config system.site.
  $mappers = \Drupal::service('plugin.manager.config_translation.mapper')
    ->getMappers();
  $mapper = $mappers['system.site_information_settings'];
  $this
    ->assertNull($config_translation_service
    ->getConfigDocumentId($mapper), 'The system.site config mapper has been disassociated from its Lingotek Document ID');
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $config_translation_service
    ->getConfigSourceStatus($mapper));

  // Ensure the UIs show the right statuses.
  $this
    ->goToContentBulkManagementForm('node');
  $this
    ->assertSourceStatusStateCount(Lingotek::STATUS_UNTRACKED, 'EN', 2, 'The nodes show as untracked');
  $this
    ->goToContentBulkManagementForm('taxonomy_term');
  $this
    ->assertSourceStatusStateCount(Lingotek::STATUS_UNTRACKED, 'EN', 2, 'The taxonomy term shows as untracked');
  $this
    ->goToConfigBulkManagementForm('config');

  // We have 4 configuration objects.
  $this
    ->assertSourceStatusStateCount(Lingotek::STATUS_UNTRACKED, 'EN', 4, 'The configuration shows as untracked');
  $this
    ->goToConfigBulkManagementForm('node_type');
  $this
    ->assertSourceStatusStateCount(Lingotek::STATUS_UNTRACKED, 'EN', 2, 'The article type shows as untracked');
}