You are here

public function LingotekContentTypeBulkDisassociateTest::testContentTypeDisassociateWithRemovalOfRemoteDocument in Lingotek Translation 8

Tests that a config entity can be disassociated using the bulk operations on the management page.

File

src/Tests/LingotekContentTypeBulkDisassociateTest.php, line 81

Class

LingotekContentTypeBulkDisassociateTest
Tests translating config using the bulk management form.

Namespace

Drupal\lingotek\Tests

Code

public function testContentTypeDisassociateWithRemovalOfRemoteDocument() {

  // This is a hack for avoiding writing different lingotek endpoint mocks.
  \Drupal::state()
    ->set('lingotek.uploaded_content_type', 'content_type');

  // Enable remote delete while disassociating.
  $edit = [
    'delete_tms_documents_upon_disassociation' => TRUE,
  ];
  $this
    ->drupalPostForm('admin/lingotek/settings', $edit, 'Save', [], [], 'lingoteksettings-tab-preferences-form');
  $this
    ->createAndTranslateContentTypeWithLinks();

  // Mark the first for disassociation.
  $edit = [
    'table[article]' => 'article',
    // Article.
    'operation' => 'disassociate',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Execute'));

  /** @var \Drupal\lingotek\LingotekConfigTranslationServiceInterface $config_translation_service */
  $config_translation_service = \Drupal::service('lingotek.config_translation');
  \Drupal::entityManager()
    ->getStorage('node_type')
    ->resetCache();
  $entity = \Drupal::entityManager()
    ->getStorage('node_type')
    ->load('article');

  // Assert that the document has been deleted remotely.
  $deleted_docs = \Drupal::state()
    ->get('lingotek.deleted_docs', []);
  $this
    ->assertEqual(1, count($deleted_docs), 'The document has been deleted remotely.');
  $this
    ->assertNull($config_translation_service
    ->getDocumentId($entity));
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $config_translation_service
    ->getSourceStatus($entity));

  // We can request again.
  $this
    ->createAndTranslateContentTypeWithLinks();
}