You are here

public function LingotekNodeBulkDisassociateTest::testNodeDisassociate in Lingotek Translation 8

Tests that a node can be translated using the links on the management page.

File

src/Tests/LingotekNodeBulkDisassociateTest.php, line 66

Class

LingotekNodeBulkDisassociateTest
Tests translating a node using the bulk management form.

Namespace

Drupal\lingotek\Tests

Code

public function testNodeDisassociate() {

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

  // Create a node.
  $edit = array();
  $edit['title[0][value]'] = 'Llamas are cool';
  $edit['body[0][value]'] = 'Llamas are very cool';
  $edit['langcode[0][value]'] = 'en';
  $edit['lingotek_translation_profile'] = 'manual';
  $this
    ->drupalPostForm('node/add/article', $edit, t('Save and publish'));
  $this
    ->createAndTranslateNodeWithLinks();
  $this
    ->goToContentBulkManagementForm();

  // Mark the first two for disassociation.
  $edit = [
    'table[1]' => TRUE,
    // Node 1.
    'operation' => 'disassociate',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Execute'));
  $node = Node::load(1);

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

  // 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($content_translation_service
    ->getDocumentId($node));
  $this
    ->assertIdentical(Lingotek::STATUS_UNTRACKED, $content_translation_service
    ->getSourceStatus($node));

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