function TMGMTNodeSourceUITestCase::testTranslateTabSingleCheckout in Translation Management Tool 7
Test the translate tab for a single checkout.
File
- sources/
node/ ui/ tmgmt_node_ui.test, line 182
Class
- TMGMTNodeSourceUITestCase
- Basic Node Source UI tests.
Code
function testTranslateTabSingleCheckout() {
// 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,
);
$this
->drupalPost(NULL, $edit, t('Request translation'));
// Verify that we are on the translate tab.
$this
->assertText(t('One job needs to be checked out.'));
$this
->assertText($node->title);
// Go to the translate tab and check if the pending translation label is
// "Unprocessed" and links to the job checkout page.
$this
->drupalGet('node/' . $node->nid . '/translate');
$this
->assertLink(t('Unprocessed'));
$this
->clickLink(t('Unprocessed'));
// Submit.
$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('German'),
)));
// 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();
// German node should now be listed and be clickable.
$this
->drupalGet('node/' . $node->nid . '/translate');
$this
->clickLink('de_' . $node->title);
// Test that the destination query argument does not break the redirect
// and we are redirected back to the correct page.
$this
->drupalGet('node/' . $node->nid . '/translate', array(
'query' => array(
'destination' => 'node',
),
));
// Request a spanish translation.
$edit = array(
'languages[es]' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Request translation'));
// Verify that we are on the checkout page.
$this
->assertText(t('One job needs to be checked out.'));
$this
->assertText($node->title);
$this
->drupalPost(NULL, array(), t('Submit to translator'));
// Make sure that we're back on the originally defined destination URL.
$this
->assertEqual(url('node', array(
'absolute' => TRUE,
)), $this
->getUrl());
}