You are here

public function LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent 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::testDisassociateOrphanContent()
  2. 4.0.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  3. 3.0.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  4. 3.1.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  5. 3.2.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  6. 3.3.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  7. 3.4.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  8. 3.6.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  9. 3.7.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()
  10. 3.8.x tests/src/Functional/LingotekUtilitiesDisassociateAllDocumentsTest.php \Drupal\Tests\lingotek\Functional\LingotekUtilitiesDisassociateAllDocumentsTest::testDisassociateOrphanContent()

Tests that we can disassociate orphan content.

This should never be an allowed status, but let's ensure that we fail gracefully. If a corresponding node doesn't exist anymore, we should just remove the existing metadata.

File

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

Class

LingotekUtilitiesDisassociateAllDocumentsTest
Tests disassociating all site documents.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testDisassociateOrphanContent() {

  // We create manually the given data for setting up an incorrect status.
  $metadata = LingotekContentMetadata::create();
  $metadata
    ->setDocumentId('a_document_id');
  $metadata
    ->setContentEntityTypeId('node');
  $metadata
    ->setContentEntityId(1);
  $metadata
    ->save();

  // Let's try to disassociate then.
  $this
    ->drupalGet('/admin/lingotek/settings');
  $this
    ->drupalPostForm('admin/lingotek/settings', [], 'Disassociate');
  $this
    ->assertRaw("Are you sure you want to disassociate everything from Lingotek?");
  $this
    ->drupalPostForm(NULL, [], 'Disassociate');
  $this
    ->assertText('All translations have been disassociated.');

  // We create manually the given data for setting up an incorrect status.
  $metadata = LingotekContentMetadata::create();
  $metadata
    ->setDocumentId('a_document_id');
  $metadata
    ->setContentEntityTypeId(NULL);
  $metadata
    ->setContentEntityId(NULL);
  $metadata
    ->save();

  // Let's try to disassociate then.
  $this
    ->drupalGet('/admin/lingotek/settings');
  $this
    ->drupalPostForm('admin/lingotek/settings', [], 'Disassociate');
  $this
    ->assertRaw("Are you sure you want to disassociate everything from Lingotek?");
  $this
    ->drupalPostForm(NULL, [], 'Disassociate');
  $this
    ->assertText('All translations have been disassociated.');
}