You are here

function TMGMTLocaleSourceTestCase::testInexistantSource in Translation Management Tool 7

Tests that system behaves correctly with an non-existing locales.

File

sources/locale/tmgmt_locale.test, line 171

Class

TMGMTLocaleSourceTestCase
Basic Locale Source tests.

Code

function testInexistantSource() {

  // Create inexistant locale object.
  $locale_object = new stdClass();
  $locale_object->lid = 0;

  // Create the job.
  $job = $this
    ->createJob();
  $job->translator = $this->default_translator->name;
  $job->settings = array();
  $job
    ->save();

  // Create the job item.
  try {
    $job
      ->addItem('locale', 'default', $locale_object->lid);
    $this
      ->fail('Job item add with an inexistant locale.');
  } catch (TMGMTException $e) {
    $this
      ->pass('Exception thrown when trying to translate non-existing locale string');
  }

  // Try to translate a source string without translation from german to
  // spanish.
  $lid = db_insert('locales_source')
    ->fields(array(
    'source' => 'No translation',
    'textgroup' => 'default',
    'context' => '',
  ))
    ->execute();
  $job = $this
    ->createJob('de', 'fr');
  $job->translator = $this->default_translator->name;
  $job->settings = array();
  $job
    ->save();
  try {
    $job
      ->addItem('locale', 'default', $lid);
    $this
      ->fail('Job item add with an non-existing locale did not fail.');
  } catch (TMGMTException $e) {
    $this
      ->pass('Job item add with an non-existing locale did fail.');
  }
}