View source
<?php
class TMGMTNodeSourceUIOverviewTestCase extends TMGMTEntityTestCaseUtility {
static function getInfo() {
return array(
'name' => 'Node Source UI Overview tests',
'description' => 'Tests the user interface for node overviews.',
'group' => 'Translation Management',
'dependencies' => array(
'rules',
),
);
}
function setUp() {
parent::setUp(array(
'tmgmt_node_ui',
));
$this
->loginAsAdmin();
$this
->setEnvironment('de');
$this
->setEnvironment('fr');
$this
->setEnvironment('es');
$this
->setEnvironment('el');
$this
->createNodeType('page', 'Page', TRANSLATION_ENABLED, FALSE);
$this
->createNodeType('untranslated', 'Untranslated', 1, FALSE);
$this
->checkPermissions(array(), TRUE);
$default_translator = tmgmt_translator_load('test_translator');
$default_translator->settings = array(
'auto_accept' => TRUE,
);
$default_translator
->save();
}
function testNodeSourceOverview() {
$this
->loginAsTranslator(array(
'translate content',
'edit any page content',
'create page content',
));
$node1 = $this
->drupalCreateNode(array(
'type' => 'page',
'language' => 'en',
'body' => array(
'en' => array(
array(),
),
),
));
$node2 = $this
->drupalCreateNode(array(
'type' => 'page',
'language' => 'en',
'body' => array(
'en' => array(
array(),
),
),
));
$node3 = $this
->drupalCreateNode(array(
'type' => 'page',
'language' => 'en',
'body' => array(
'en' => array(
array(),
),
),
));
$node4 = $this
->drupalCreateNode(array(
'type' => 'page',
'language' => 'en',
'body' => array(
'en' => array(
array(),
),
),
));
$node5 = $this
->drupalCreateNode(array(
'type' => 'page',
));
$node6 = $this
->drupalCreateNode(array(
'type' => 'untranslated',
'language' => 'en',
'body' => array(
'en' => array(
array(),
),
),
));
$this
->drupalGet('admin/tmgmt/sources/node');
$this
->assertText($node1->title);
$this
->assertText($node2->title);
$this
->assertText($node3->title);
$this
->assertText($node4->title);
$this
->assertNoText($node5->title);
$this
->assertNoText($node6->title);
$edit = array(
'views_bulk_operations[0]' => TRUE,
'views_bulk_operations[1]' => TRUE,
'views_bulk_operations[2]' => TRUE,
);
$this
->drupalPost(NULL, $edit, t('Request translations'));
$this
->assertText(t('@title and 2 more (English to ?, Unprocessed)', array(
'@title' => $node1->title,
)));
$this
->assertText($node1->title);
$this
->assertText($node2->title);
$this
->assertText($node3->title);
$this
->assertNoText($node4->title);
$edit = array(
'target_language' => 'de',
);
$this
->drupalPost(NULL, $edit, t('Submit to translator'));
$this
->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
'@title' => $node1->title,
'@language' => t('German'),
)));
$this
->assertText(t('The translation for @title has been accepted.', array(
'@title' => $node1->title,
)));
$this
->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
'@title' => $node2->title,
'@language' => t('German'),
)));
$this
->assertText(t('The translation for @title has been accepted.', array(
'@title' => $node1->title,
)));
$this
->assertNoText(t('The translation of @title to @language is finished and can now be reviewed.', array(
'@title' => $node3->title,
'@language' => t('German'),
)));
$this
->assertText(t('The translation for @title has been accepted.', array(
'@title' => $node1->title,
)));
$this
->clickLink($node1->title);
$this
->clickLink(t('Translate'));
$this
->assertText('de_' . $node1->title);
$view = views_get_view('tmgmt_node_source_overview');
$view
->execute_display('default');
$this
->assertEqual($view
->get_items_per_page(), variable_get('tmgmt_source_list_limit', 20));
$node_not_translated = $this
->drupalCreateNode(array(
'type' => 'page',
'language' => 'en',
'body' => array(
'en' => array(
array(),
),
),
));
$node_de = $this
->drupalCreateNode(array(
'type' => 'page',
'language' => 'de',
'body' => array(
'de' => array(
array(),
),
),
));
$this
->drupalGet('admin/tmgmt/sources/node');
$this
->assertText($node1->title);
$this
->assertText($node_not_translated->title);
$this
->assertText($node_de->title);
$this
->drupalGet('admin/tmgmt/sources/node', array(
'query' => array(
'tmgmt_node_missing_translation' => 'de',
'target_status' => 'untranslated',
),
));
$this
->assertNoText($node1->title);
$this
->assertText($node_not_translated->title);
$this
->assertNoText($node_de->title);
db_update('node')
->fields(array(
'translate' => 1,
))
->condition('nid', $node1->nid)
->execute();
$this
->drupalGet('admin/tmgmt/sources/node', array(
'query' => array(
'tmgmt_node_missing_translation' => 'de',
'target_status' => 'outdated',
),
));
$this
->assertText($node1->title);
$this
->assertNoText($node_not_translated->title);
$this
->assertNoText($node_de->title);
$this
->drupalGet('admin/tmgmt/sources/node', array(
'query' => array(
'tmgmt_node_missing_translation' => 'de',
'target_status' => 'untranslated_or_outdated',
),
));
$this
->assertText($node1->title);
$this
->assertText($node_not_translated->title);
$this
->assertNoText($node_de->title);
}
}