You are here

function TMGMTNodeSourceUITestCase::testTranslateTabMultipeCheckout in Translation Management Tool 7

Test the translate tab for a single checkout.

File

sources/node/ui/tmgmt_node_ui.test, line 256

Class

TMGMTNodeSourceUITestCase
Basic Node Source UI tests.

Code

function testTranslateTabMultipeCheckout() {

  // Create a user that is allowed to translate nodes.
  $translater = $this
    ->drupalCreateUser(array(
    'translate content',
    'create translation jobs',
    'submit translation jobs',
    'accept translation jobs',
  ));
  $this
    ->drupalLogin($translater);

  // Create an english source node.
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'page',
    'language' => 'en',
    'body' => array(
      'en' => array(
        array(),
      ),
    ),
  ));

  // Go to the translate tab.
  $this
    ->drupalGet('node/' . $node->nid);
  $this
    ->clickLink('Translate');

  // Assert some basic strings on that page.
  $this
    ->assertText(t('Translations of @title', array(
    '@title' => $node->title,
  )));
  $this
    ->assertText(t('Pending Translations'));

  // Request a translation for german.
  $edit = array(
    'languages[de]' => TRUE,
    'languages[es]' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Request translation'));

  // Verify that we are on the translate tab.
  $this
    ->assertText(t('2 jobs need to be checked out.'));

  // Submit all jobs.
  $this
    ->assertText($node->title);
  $this
    ->drupalPost(NULL, array(), t('Submit to translator and continue'));
  $this
    ->assertText($node->title);
  $this
    ->drupalPost(NULL, array(), t('Submit to translator'));

  // Make sure that we're back on the translate tab.
  $this
    ->assertEqual(url('node/' . $node->nid . '/translate', array(
    'absolute' => TRUE,
  )), $this
    ->getUrl());
  $this
    ->assertText(t('Test translation created.'));
  $this
    ->assertText(t('The translation of @title to @language is finished and can now be reviewed.', array(
    '@title' => $node->title,
    '@language' => t('Spanish'),
  )));

  // Review.
  $this
    ->clickLink(t('Needs review'));

  // @todo Review job throuh the UI.
  $items = tmgmt_job_item_load_latest('node', 'node', $node->nid, 'en');
  $items['de']
    ->acceptTranslation();
  $items['es']
    ->acceptTranslation();

  // Translated nodes should now be listed and be clickable.
  $this
    ->drupalGet('node/' . $node->nid . '/translate');
  $this
    ->clickLink('de_' . $node->title);

  // Translated nodes should now be listed and be clickable.
  $this
    ->drupalGet('node/' . $node->nid . '/translate');
  $this
    ->clickLink('es_' . $node->title);
}