You are here

public function LingotekContentTypeBulkDisassociateTest::testContentTypeDisassociate 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 46

Class

LingotekContentTypeBulkDisassociateTest
Tests translating config using the bulk management form.

Namespace

Drupal\lingotek\Tests

Code

public function testContentTypeDisassociate() {

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

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $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 no document has been deleted remotely.
  $deleted_docs = \Drupal::state()
    ->get('lingotek.deleted_docs', []);
  $this
    ->assertEqual(0, count($deleted_docs), 'No document has been deleted remotely because the module is not configured to perform the operation.');
  $this
    ->assertNull($config_translation_service
    ->getDocumentId($entity));
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $config_translation_service
    ->getSourceStatus($entity));

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