function TMGMTNodeSourceUITestCase::testTranslateTabAutomatedCheckout in Translation Management Tool 7
Test the translate tab for a single checkout.
File
- sources/
node/ ui/ tmgmt_node_ui.test, line 313
Class
- TMGMTNodeSourceUITestCase
- Basic Node Source UI tests.
Code
function testTranslateTabAutomatedCheckout() {
// Hide settings on the test translator.
$default_translator = tmgmt_translator_load('test_translator');
$default_translator->settings = array(
'expose_settings' => FALSE,
);
$default_translator
->save();
// 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
->assertNoText(t('One job needs to be checked out.'));
// 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);
}