You are here

public function LingotekFieldBodyBulkDisassociateTest::testFieldDisassociate in Lingotek Translation 8

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

File

src/Tests/LingotekFieldBodyBulkDisassociateTest.php, line 50

Class

LingotekFieldBodyBulkDisassociateTest
Tests disassociating a field using the bulk management form.

Namespace

Drupal\lingotek\Tests

Code

public function testFieldDisassociate() {

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->createAndTranslateFieldWithLinks();

  // Mark the first for disassociation.
  $edit = [
    'table[node.article.body]' => 'node.article.body',
    // 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('field_config')
    ->resetCache();
  $entity = \Drupal::entityManager()
    ->getStorage('field_config')
    ->load('node.article.body');

  // 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
    ->createAndTranslateFieldWithLinks();
}