You are here

public function LingotekNodeBulkDebugTest::testDebugExport in Lingotek Translation 8

File

src/Tests/LingotekNodeBulkDebugTest.php, line 84

Class

LingotekNodeBulkDebugTest
Tests debugging a node using the bulk management form.

Namespace

Drupal\lingotek\Tests

Code

public function testDebugExport() {

  // 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'));

  // Enable the debug operations.
  $this
    ->drupalGet('admin/lingotek/settings');
  $this
    ->drupalPostForm(NULL, [], t('Enable debug operations'));
  $this
    ->goToContentBulkManagementForm();
  $edit = [
    'table[1]' => TRUE,
    // Node 1.
    'operation' => 'debug.export',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Execute'));
  $this
    ->assertText('Exports available');

  // Download the file.
  $this
    ->clickLink('node.article.1.json');
  $response = json_decode($this->content, true);
  $this
    ->assertIdentical('Llamas are cool', $response['title'][0]['value']);
  $this
    ->assertIdentical('Llamas are very cool', $response['body'][0]['value']);
  $this
    ->assertIdentical('article (node): Llamas are cool', $response['_debug']['title']);
  $this
    ->assertIdentical('manual', $response['_debug']['profile']);
  $this
    ->assertIdentical('en_US', $response['_debug']['source_locale']);
}