123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /**
- * Basic Locale Source tests.
- */
- class TMGMTLocaleSourceUiTestCase extends TMGMTBaseTestCase {
- static function getInfo() {
- return array(
- 'name' => 'Locale Source UI tests',
- 'description' => 'Tests the locale source overview',
- 'group' => 'Translation Management',
- );
- }
- function setUp() {
- parent::setUp(array('tmgmt_locale', 'tmgmt_ui'));
- $this->langcode = 'de';
- $this->context = 'default';
- $file = new stdClass();
- $file->uri = drupal_realpath(drupal_get_path('module', 'tmgmt_locale') . '/tests/test.xx.po');
- $this->pofile = file_save($file);
- $this->setEnvironment($this->langcode);
- $this->setEnvironment('gsw-berne');
- }
- public function testOverview() {
- // Load PO file to create a locale structure in the database.
- _locale_import_po($this->pofile, $this->langcode, LOCALE_IMPORT_OVERWRITE, $this->context);
- $this->loginAsTranslator();
- $this->drupalGet('admin/tmgmt/sources/locale_default');
- $this->assertText('Hello World');
- $this->assertText('Example');
- $rows = $this->xpath('//tbody/tr');
- foreach ($rows as $row) {
- if ($row->td[1] == 'Hello World') {
- $this->assertEqual((string) $row->td[3]->div['title'], t('Translation up to date'));
- $this->assertEqual((string) $row->td[4]->div['title'], t('Not translated'));
- }
- }
- // Filter on the label.
- $edit = array('search[label]' => 'Hello');
- $this->drupalPost(NULL, $edit, t('Search'));
- $this->assertText('Hello World');
- $this->assertNoText('Example');
- $locale_object = db_query('SELECT * FROM {locales_source} WHERE source = :source LIMIT 1', array(':source' => 'Hello World'))->fetchObject();
- // First add source to the cart to test its functionality.
- $edit = array(
- 'items[' . $locale_object->lid . ']' => TRUE,
- );
- $this->drupalPost(NULL, $edit, t('Add to cart'));
- $this->assertRaw(t('@count content source was added into the <a href="@url">cart</a>.', array('@count' => 1, '@url' => url('admin/tmgmt/cart'))));
- $edit['target_language[]'] = array('gsw-berne');
- $this->drupalPost('admin/tmgmt/cart', $edit, t('Request translation'));
- // Assert that the job item is displayed.
- $this->assertText('Hello World');
- $this->assertText(t('Locale'));
- $this->assertText('2');
- $this->drupalPost(NULL, array('target_language' => 'gsw-berne'), t('Submit to translator'));
- // Test for the translation flag title.
- $this->drupalGet('admin/tmgmt/sources/locale_default');
- $this->assertRaw(t('Active job item: Needs review'));
- // Review and accept the job item.
- $job_items = tmgmt_job_item_load_latest('locale', 'default', $locale_object->lid, 'en');
- $this->drupalGet('admin/tmgmt/items/' . $job_items['gsw-berne']->tjiid);
- $this->assertRaw('gsw-berne_Hello World');
- $this->drupalPost(NULL, array(), t('Save as completed'));
- $this->drupalGet('admin/tmgmt/sources/locale_default');
- $this->assertNoRaw(t('Active job item: Needs review'));
- $rows = $this->xpath('//tbody/tr');
- foreach ($rows as $row) {
- if ($row->td[1] == 'Hello World') {
- $this->assertEqual((string) $row->td[3]->div['title'], t('Translation up to date'));
- $this->assertEqual((string) $row->td[4]->div['title'], t('Translation up to date'));
- }
- }
- // Test the missing translation filter.
- $this->drupalGet('admin/tmgmt/sources/locale_default');
- // Check that the source language (en) has been removed from the target language
- // select box.
- $elements = $this->xpath('//select[@name=:name]//option[@value=:option]', array(':name' => 'search[target_language]', ':option' => 'en'));
- $this->assertTrue(empty($elements));
- // Filter on the "Not translated to".
- $edit = array('search[missing_target_language]' => 'gsw-berne');
- $this->drupalPost(NULL, $edit, t('Search'));
- // Hello World is translated to "gsw-berne" therefore it must not show up in the
- // list.
- $this->assertNoText('Hello World');
- }
- }
|