You are here

function TMGMTEntitySourceUITestCase::testNodeTranslateTabMultipeCheckout in Translation Management Tool 7

Test the translate tab for a single checkout.

File

sources/entity/ui/tmgmt_entity_ui.test, line 160

Class

TMGMTEntitySourceUITestCase
Basic Node Source tests.

Code

function testNodeTranslateTabMultipeCheckout() {

  // Allow auto-accept.
  $default_translator = tmgmt_translator_load('test_translator');
  $default_translator->settings = array(
    'auto_accept' => TRUE,
  );
  $default_translator
    ->save();
  $this
    ->loginAsTranslator(array(
    'translate node entities',
  ));

  // Create an english source node.
  $node = $this
    ->createNode('page', 'en');

  // 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
    ->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
    '@title' => $node->title,
    '@language' => t('Spanish'),
  )));
  $this
    ->assertText(t('The translation for @title has been accepted.', array(
    '@title' => $node->title,
  )));

  // Translated nodes should now be listed and be clickable.
  // @todo Use links on translate tab.
  $this
    ->drupalGet('de/node/' . $node->nid);
  $this
    ->assertText('de_' . $node->body['en'][0]['value']);
  $this
    ->drupalGet('es/node/' . $node->nid);
  $this
    ->assertText('es_' . $node->body['en'][0]['value']);
}